Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends

I have DataGridView in Window form. There is one column which is binding with Text row and Image Row. Column Type is GridViewTextBoxColumn.
But my requirement is that Value is either in Text format or Image format. If it is Text Format then it display but if it is image format then how to bind that image in same column.

For example
C#
foreach (MyClassObject q in qList)
{
   if (q.IsImage){
         gridMC.Rows[c].Cells[1].Value = q.ImageValue; // Image Object
   }else{
         gridMC.Rows[c].Cells[1].Value = q.TextValue;
   }
}
//gridMC is my GridView


Thanks
Imrankhan
Posted

Why don't you keep 2 columns. One for text and other for image. And depending upon your requirement you just change the visibility.
if you want to show image column then change its visibility to true and text column to false and vice-versa.
 
Share this answer
 
Hi In DataGridView go Propertys and add column at that time columntype u can choose Datagridimagecolumn. u will get image.
 
Share this answer
 
Comments
Member 9508793 18-Nov-12 1:44am    
i was displaying the images in the datagridview. but when i went to display the gray scale images then it won't display. plz solve my problem.
the few ways
1. go and get a commercial component like infragistics wingrid that fits your needs
2. search for something called "textimagecolumn", a some guy has implemented a (maybe not suitable) solution in this manner...
3. write your own custom column class, e.g. overwrite the paint event an paint cells yourself
4. wait till the microsoft guys come across this flaw
5. or die meanwhile ;-)

I have to struggle with this myself. It's a damn shame this clumsy, inconvenient implementation of the datagridview.
 
Share this answer
 
v2

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