DataGridViewImageColumn
-
Hi Is it possible to show different image in one column in each row depending on status of other column in the grid? For example: stop o running ~ waiting x I wouldn't like to create my own class representing ImageCell. Just using CellPainting event. I do like this in CellPainting: e.Graphics.DrawImage(img, e.CellBounds); img depends on value of another column (status) ...but it doesn't work. Image is drawn and disappears Thanks Ela
-
Hi Is it possible to show different image in one column in each row depending on status of other column in the grid? For example: stop o running ~ waiting x I wouldn't like to create my own class representing ImageCell. Just using CellPainting event. I do like this in CellPainting: e.Graphics.DrawImage(img, e.CellBounds); img depends on value of another column (status) ...but it doesn't work. Image is drawn and disappears Thanks Ela
e_LA wrote:
Image is drawn and disappears
It's hard to help you without seeing the context of the drawing code. If it's drawn but then disappears, either you're drawing code is wrong or you're drawing in the wrong place.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
e_LA wrote:
Image is drawn and disappears
It's hard to help you without seeing the context of the drawing code. If it's drawn but then disappears, either you're drawing code is wrong or you're drawing in the wrong place.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Ok When I put only such a code in cellpainting event private void myDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex > -1 && e.RowIndex > -1) { Image img = global::MyApplication.Properties.Resources.GreenImage; e.Graphics.DrawImage(img, e.CellBounds); } } Anything is drawn. Why? In fact it is drawn and dissapears - I checked it. What is wrong?
-
Ok When I put only such a code in cellpainting event private void myDataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex > -1 && e.RowIndex > -1) { Image img = global::MyApplication.Properties.Resources.GreenImage; e.Graphics.DrawImage(img, e.CellBounds); } } Anything is drawn. Why? In fact it is drawn and dissapears - I checked it. What is wrong?
Instead of setting up a CellPainting handler, define a DataGridViewCell type and override the Paint method, then put your painting code inside that overridden method.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Instead of setting up a CellPainting handler, define a DataGridViewCell type and override the Paint method, then put your painting code inside that overridden method.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Instead of setting up a CellPainting handler, define a DataGridViewCell type and override the Paint method, then put your painting code inside that overridden method.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Ok I defined my own class representing column and cell class where I overriden a Paint method. In the Paint method I would like to draw image depending on value of another column. I have to take DataSource (DataView) where I could check the value in another column in the same row (RowIndex). That's why I created cell constructor like that public ImageCell(DataGridView dGridV) { this.grid = dGridV; } When in Paint method I put such a line DataView dv = (DataView)grid.DataSource; I have an exception because grid is null. I think during adding column to grid operation default constructor of the cell is called (which is empty in my case). Am I right? Thanks Ela
-
Instead of setting up a CellPainting handler, define a DataGridViewCell type and override the Paint method, then put your painting code inside that overridden method.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Messianic Instrumentals (with audio) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Yes, it works now. I have only message on Console window: FormattedValueType property of a cell cannot be null. I tried to override FormattedValueType property but it doesn't not works. Another thing is sometimes I have to display animated gif in the cell. However when I want to animate gif I have to call Invalidate method which does not exist for the cell. Thanks Ela