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

grid view image column

9 Answers 280 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Oscar Zapata
Top achievements
Rank 1
Oscar Zapata asked on 01 Mar 2010, 04:33 AM
Hi!!!


i need to create a gridviewimagecolumn in code-behind, i add the reference to the assembly (telerik.windows.controls and telerik.windows.controls.gridview) but i cant find the class gridviewimagecolumn, i cant use it.


i am using the trival version of q3 2009 sp2 release


what can i do???

thanks for your help
my best wishes

9 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 01 Mar 2010, 08:00 AM
Hello Oscar Zapata,

That is very strange since the image column is located in the Telerik.Windows.Controls.GridView assembly (in namespace Telerik.Windows.Controls). Could you please verify that you have declared a using statement for the Telerik.Windows.Controls namespace.

Also, you should add two additional assemblies to your project - Telerik.Windows.Controls.Input and Telerik.Windows.Data.


Regards,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Oscar Zapata
Top achievements
Rank 1
answered on 01 Mar 2010, 04:18 PM

thanks for your help milan!!!

the reference for the assmbly was not the correct when i add the reference for the correct assembly the class  now  appears.

now in code-behind, i have a dataset with a column that contains image in byte()  format, that i want is to display the images in the gidviewimagecolumn.



have i to deserialize the image or what can i do???


tahnks for your help ,
my best wishes



0
Vlad
Telerik team
answered on 02 Mar 2010, 07:56 AM
Hello,

If you set DataMemberBinding for this column to point to your image field name the grid will show the image automatically.

All the best,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael Blanchet
Top achievements
Rank 1
answered on 08 Sep 2010, 10:51 PM
I cannot get an image showing in the RadGridView. I had initially thought that having a datacolumn type of Image in the DataTable used as the datasource for the grid would display the image, but this is not the case (why not?)

So I changed the code to add each GridViewColumn to the grid based on the Columns in the datatable. All of the data columns display properly except the image column. The image column corresponding the Image column in the datatable is defined as follows:
            GridViewImageColumn IDCL = new GridViewImageColumn();
            GridControl.Columns.Add(IDCL);
            IDCL.DataType = typeof(System.Drawing.Image);
            IDCL.ImageHeight = 75;
            IDCL.ImageWidth = 75;
            IDCL.DataMemberBinding = new Binding("ImageCol");

This displays nothing although the DataTable which is assigned to the GridControl.ItemSource has a column ImageCol of type Image and a number of rows with Image data present.

Next, I changed the ImageCol Column in the datatable to Binary (byte[]) and changed the image column correspondingly as follows:
            GridViewImageColumn IDCL = new GridViewImageColumn();
            GridControl.Columns.Add(IDCL);
            IDCL.DataType = typeof(System.Byte[]);
            IDCL.ImageHeight = 75;
            IDCL.ImageWidth = 75;
            IDCL.DataMemberBinding = new Binding("ImageCol");

It still does not work. What am I doing wrong? (It should not be this hard)


0
Vlad
Telerik team
answered on 09 Sep 2010, 07:27 AM
Hi,

 Can you verify if you can display normally these images in a plain Image control?

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael Blanchet
Top achievements
Rank 1
answered on 09 Sep 2010, 06:45 PM
I can display the same byte[] value in a WPF Image control - I have to convert it to an Imaging.BitmapImage first however. The byte[] value contains a valid png image (and I have tried jpeg) - I see nothing in the grid.
0
Michael Blanchet
Top achievements
Rank 1
answered on 09 Sep 2010, 08:51 PM
On further investigation - I am getting the following Binding Error:
Binding Error: System.Windows.Data Error: 40 : BindingExpression path error: 'ImageCol' property not found on 'object' ''DataRow' (HashCode=45639444)'. BindingExpression:Path=ImageCol; DataItem='DataRow' (HashCode=45639444); target element is 'Image' (Name=''); target property is 'Source' (type 'ImageSource')

And yet, the 'ImageCol' column is in the DataTable (and each Row) passed to the Grid ItemSource. The ImageCol contains valid byte[] data which can be displayed in the Image control as described in my last post.

You need to provide better support for this item, I have wasted 2 days trying to get your grid to work as advertised.
0
Vlad
Telerik team
answered on 10 Sep 2010, 07:07 AM
Hello,

 Binding in WPF to indexer should be with following syntax:

new Binding("[ImageCol]");

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael Blanchet
Top achievements
Rank 1
answered on 10 Sep 2010, 03:12 PM
Thanks, that works.

It would have been really useful if that was pointed out in the documentation in the defining columns section - the example you have just shows a class and not a datatable which is probably the more common scenario.
Tags
GridView
Asked by
Oscar Zapata
Top achievements
Rank 1
Answers by
Milan
Telerik team
Oscar Zapata
Top achievements
Rank 1
Vlad
Telerik team
Michael Blanchet
Top achievements
Rank 1
Share this question
or