Binding DataGridViewImageColumn in DataGridView
Dear all,
I would like to binding (string or bool) data from database in DataGridViewImageColumn. However, i catch exception in DataGridView_Error event when i run it. Exception message is Formating error or Commit error.
Please help me to resolve my problems and give me example code if possible.
Thanks for your help.
Khiem Vo.
[342 byte] By [
khiemvo] at [2007-12-16]
The Image column only supports binding to a byte array, not to a string or bool data. You'll need to manually convert the string or bool to an image in the CellFormatting event.
Hope this helps,
-mark
DataGridView Program Manager
Microsoft
This post is provided "as-is"
Let me describe what that sample is doing -- In a DataGridViewImageColumn (called Priority) the data for that column is a string but in this case you want to show an image instead. So the example handles the CellFormatting event and replaces the string value with the appropriate image based upon the priority.
Handling the CellFormatting and converting the string to an image makes the DataGridViewImageColumn think it is really bound to an image, since you are changing the formatted value.
Hope this helps!
-mark
DataGridView Progam Manager
Microsoft
This post is provided "as-is"
I keep getting the following error when I try to load the form.
"An error occurred creating the form. See Exception.InnerException for details. The error is: Parameter is not valid."
The error is on this part of the MDIParent frmProjects.MdiParent =
MeWhere frmProjects is the form containing the code from the link.The database field is set to "Text" (system.string) & I have tried the datagridview with both string and image types.
Any help would be greatly appreciated.
Nevermind. I had to copy the .bmp files to the debug folder (same as .exe) & also set my default value for "Priority" (I set mine to 'Low') in the .xsd file.
Otherwise I would get errors.
Vwalla