Datagrid -> still no solution
Dear Programmer,
I have been having this problem since the beginning, I am programming in VB.Net -> EXE file (NOT ASP.NET) and I'm still not able to put a image (from a imagelist) in a datagrid. Can somebody please help me, this is irritating me :S
DATAGRID example:
----------------------------------------------------------------
1 ___ OK _______ Imagelist1.PictureOK.jpg
2 ___ NOT OK ___ Imagelist1.PictureNotOK.jpg
----------------------------------------------------------------
Its is for the Windows gird not the Asp.net grid
I just tried out the code it works at my end. You can refer to the following code:
DataGridTableStyle DGStyle;
DataGridColumnStyle GridTextColumn, GridBmpColumn;
DGStyle = new DataGridTableStyle();
// select table
DGStyle.MappingName = "Test";
// get the PropertyDescriptorCollection for the data
// source and data member.
PropertyDescriptorCollection pcol =
this.BindingContext[DBDataSet,
"Test"].GetItemProperties();
// create column style for a text column
GridTextColumn = new DataGridTextBoxColumn(pcol["Description"]);
GridTextColumn.MappingName = "Description";
GridTextColumn.HeaderText = "Icon-Name";
GridTextColumn.Width = 200;
DGStyle.GridColumnStyles.Add(GridTextColumn);
// create column style for an image column
GridBmpColumn = new DataGridImageColumn(pcol["Images"]);
GridBmpColumn.MappingName = "Images";
GridBmpColumn.HeaderText = "Bitmap";
GridBmpColumn.Width = 100;
DGStyle.GridColumnStyles.Add(GridBmpColumn);
// add table style to the data grid
dataGrid1.TableStyles.Add(DGStyle);
// connect grid with database
dataGrid1.DataSource = DBDataSet;
dataGrid1.DataMember = DBDataSet.Tables["Test"].TableName;
Above code can be tried if you want to download the version from the site you can refer to the following link:
http://www.codeguru.com/Csharp/Cshar...cle.php/c4783/