Picture column with URL in RadDataGrid

9 posts, 0 answers
  1. Zlatko Rusev
    Zlatko Rusev avatar
    21 posts
    Member since:
    Oct 2009

    Posted 03 Nov 2009 Link to this post

    Hello,

    My question is how I can use in RadDataGrid a picture column using URL, not image from database

    Best Regards
    Zlatko Rusev
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Nov 2009 Link to this post

    Hi Zlatko Rusev,

    You could use GridImageColumn to achieve the required functionality.
           Set the ImageUrl property to a static value in order to appear the same in the entire column. You can set the DataImageUrlFields property to a field in the source that can be used to supply the image path and format it by setting the DataImageUrlFormatString property.

    For more information, checkout the part "GridImageColumn" in the following documentation: Column types

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 03 Nov 2009 Link to this post

    Hi Zlatko,

    You can use the built-in GridImageColumn for this purpose as presented on the following online demo of RadGrid for ASP.NET AJAX:
    http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx

    Greetings,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Zlatko Rusev
    Zlatko Rusev avatar
    21 posts
    Member since:
    Oct 2009

    Posted 04 Nov 2009 Link to this post

    Hi,

    Maybe I don't explain quite good, I meen WinForms GridView
    And the pictures are stored in web site directory

    Z.Rusev
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 05 Nov 2009 Link to this post

    Hello Zlatko Rusev,

    RadGridView displays images either taken from a database or provided by the developer as Image objects. The rest of the scenario where the images are downloaded from a web site and converted to Image objects is custom and it requires implementation from your side.

    If you have additional questions, feel free to contact me.

    Best wishes,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Zlatko Rusev
    Zlatko Rusev avatar
    21 posts
    Member since:
    Oct 2009

    Posted 06 Nov 2009 Link to this post

    Hi Nikolay,

    Again, my application is Desktop one, and I have to use GridView (?) control for WinForms. It's not web site !
    And other question is if a image (source -from directory) has random size, how I can set to be in custom size, and don't want  free apace up & down of its in column cell

    Thank you for answer
    Z.Rusev
  8. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 16 Nov 2009 Link to this post

    Hello Zlatko Rusev,

    My previous reply was about RadGridView for WinForms. When your images are not contained in a database, but they are contained at a custom directory, you need to create Image objects from them and assign these image objects to the cells in the GridViewImageColumn:

    List<Image> images = new List<Image>();
      
    private void Form1_Load(object sender, EventArgs e)
    {
        this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
      
        GetImages();
      
        GridViewImageColumn imageCol = new GridViewImageColumn();
        imageCol.UniqueName = "Images";
        this.radGridView1.Columns.Add(imageCol);
      
        for (int i = 0; i < this.radGridView1.Rows.Count; i++)
        {
            this.radGridView1.Rows[i].Cells["Images"].Value = images[i];
        }
    }
      
    private void GetImages()
    {
        // Fill the images list
    }

    As to your second question, you can resize an image by creating a new Bitmap from the Image objects that you get from the directory:

    Bitmap resizedBitmap = new Bitmap(originalBitmap, new Size(12, 12));

    Another option is to set the ImageLayout of the GridViewImageColumn to Stretch. This will make the image fill the cell:

    GridViewImageColumn imageCol = new GridViewImageColumn();
    imageCol.UniqueName = "Images";
    imageCol.ImageLayout = ImageLayout.Stretch;
    this.radGridView1.Columns.Add(imageCol);

    I hope this helps. If you have additional questions, feel free to contact me.

    Best wishes,

    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Luca
    Luca avatar
    1 posts
    Member since:
    Jun 2013

    Posted 25 Jun 2013 Link to this post

    what if the bitmap is in 'Resources' like Properties.Resources.mypicture ?
    thanks
    luca
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Jun 2013 Link to this post

    Hello Luca,

    It does not matter where your image is, you just need to assign an Image object as a cell value in the image column:
    this.radGridView1.Rows[0].Cells["Images"].Value = Resources.Image11;

    I hope this helps.

    Best Wishes, Stefan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017