How to bind images to DataGridView in windows application
I have a windows application.I am binding datagridview with a dataset which contains values from database.In datase开发者_运维问答t onecolumn is status.It contains values as 1 or 2 or 3 like wise integers.If value is 1 instead of displaying 1 i want to bind image 1.jpg from Images folder,and instead of displaying 2 i want to bind image 2.jpg likewise.Can anybody help?
Create an ImageList with the images you would like to show in your cell, make the index of the image the same as the ones in the DB. (You could use an embedded resource to do the mapping if you wanted to do that, just depends on whether these images are specific to the form you are using)
Then in the CellPainting event, set the source of the DataGridViewImageColumn to be the image in the ImageList based on the value of the cell.
精彩评论