Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
Good day all!!!

I have two columns "IsTrue" and "IsTrueImage" in my DataGridView. "IsTrueImage" is a image column.

I want to set the image for the individual image cells based on the whether or not the cell value for "IsTrue" is true or false.

I'm not sure how to go about this. CellFormatting, RowPrePaint, RowPostPaint.


Thanx in advance...
Posted

_AKA_KSN_: I understand you like to write posts; what I don't understand is your answer to azinyama.

- When did he mention DataTemplateSelector?

"You hope he might be talking it" ??? Did you even _read_ the question? Why would he be talking about it, if he doesn't write about it?

people like you really strengthen the myth: Random Internet people just dont care.

However; and back to answering OP.

It seems that using the cellformatting event, might be the way to go.

Here's a few threads about it, Azin.

http://johnroach.info/2012/01/13/how-to-add-images-to-datagridview-cell-using-c-and-windows-forms/

http://www.visualwebgui.com/Developers/Community/Projects/ApplicationVEM/Forums/tabid/179/forumid/29/postid/7169/scope/posts/Default.aspx
 
Share this answer
 
v2
Hi,

hope you might be talking about DataTemplateSelector please follow the below link. or let me know if am wrong.

http://msdn.microsoft.com/en-us/library/system.windows.controls.datatemplateselector(v=VS.85).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900