This is a migrated thread and some comments may be shown as answers.

Picture column with URL in RadDataGrid

8 Answers 369 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zlatko Rusev
Top achievements
Rank 1
Zlatko Rusev asked on 03 Nov 2009, 07:44 AM
Hello,

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

Best Regards
Zlatko Rusev

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Nov 2009, 08:36 AM
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.
0
Sebastian
Telerik team
answered on 03 Nov 2009, 08:37 AM
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.
0
Zlatko Rusev
Top achievements
Rank 1
answered on 04 Nov 2009, 07:17 PM
Hi,

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

Z.Rusev
0
Nikolay
Telerik team
answered on 05 Nov 2009, 04:16 PM
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.
0
Zlatko Rusev
Top achievements
Rank 1
answered on 06 Nov 2009, 08:19 AM
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
0
Nikolay
Telerik team
answered on 16 Nov 2009, 11:39 AM

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.
0
Luca
Top achievements
Rank 1
answered on 25 Jun 2013, 09:10 AM
what if the bitmap is in 'Resources' like Properties.Resources.mypicture ?
thanks
luca
0
Stefan
Telerik team
answered on 28 Jun 2013, 06:07 AM
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.
Tags
Grid
Asked by
Zlatko Rusev
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sebastian
Telerik team
Zlatko Rusev
Top achievements
Rank 1
Nikolay
Telerik team
Luca
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or