pictures in a datagrid
-
How can I in my winform display picture or icons in one of the columns in my datagrid?
-
How can I in my winform display picture or icons in one of the columns in my datagrid?
By writing your own
DataGridColumnStyle
class. There are many examples out there that describe hosting aComboBox
in aDataGridColumnStyle
, and these wouldn't be hard to adapt and use aPictureBox
instead. If you want, you wouldn't even have to worry about the editing if you want this image to be read-only (the editing is the most difficult part). Just make sure your query returns a BLOB (which you can read into aStream
, like aMemoryStream
) or a path to an image. For a good example of hosting aComboBox
in aDataGridColumnStyle
, see http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/[^]. It includes examples and sample source.Microsoft MVP, Visual C# My Articles