Click here to Skip to main content
Sign Up to vote bad
good
See more: C#
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
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 22 May '12 - 23:03


3 solutions

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.
  Permalink  
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 Wink | ;-)
 
I have to struggle with this myself. It's a damn shame this clumsy, inconvenient implementation of the datagridview.
  Permalink  
Hi In DataGridView go Propertys and add column at that time columntype u can choose Datagridimagecolumn. u will get image.
  Permalink  
Comments
Member 9508793 - 18 Nov '12 - 1:44
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.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 479
1 Arun Vasu 253
2 OriginalGriff 210
3 CPallini 163
4 Aarti Meswania 158
0 Sergey Alexandrovich Kryukov 10,129
1 OriginalGriff 7,749
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 2,999


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 23 May 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid