JamesAStewart
asked on
Multiple images and text/custom control in one datagridview cell
I would like some advice on the best way to add multiple images to a single cell in the datagridview. (VB.net 2005)
I need to add 8 single images and a small amount of text to a single cell - because of the variations of data available, it's not possible to create a series of single images to cover the different permutations that may need to be displayed. In addition to these 8 images, I need to add (if possible) some text after the images.
I'm creating the datagridview manually using:
datagridview1.rows.Add(str ing1,strin g2,string3 ,bitmaps,s tring4,str ing5)
Currently I can add one image but I'm unsure as to how to progress adding multiple images. Would a custom control be the right solution - if so how do I go about achieving it?
Thanks in advance
James
I need to add 8 single images and a small amount of text to a single cell - because of the variations of data available, it's not possible to create a series of single images to cover the different permutations that may need to be displayed. In addition to these 8 images, I need to add (if possible) some text after the images.
I'm creating the datagridview manually using:
datagridview1.rows.Add(str
Currently I can add one image but I'm unsure as to how to progress adding multiple images. Would a custom control be the right solution - if so how do I go about achieving it?
Thanks in advance
James
ASKER
I've found a solution:
Derive a class from DataGridViewTextBoxCell
Override the paint method
Derive a class from DataGridViewColumn - make the cell template = the above new Cell class
An example can be found here:
http://msdn2.microsoft.com/en-us/library/7fb61s43.aspx
It uses rollover to paint a box onto a cell. This can easily be adapted to paint numerous images, text excetera.
Derive a class from DataGridViewTextBoxCell
Override the paint method
Derive a class from DataGridViewColumn - make the cell template = the above new Cell class
An example can be found here:
http://msdn2.microsoft.com/en-us/library/7fb61s43.aspx
It uses rollover to paint a box onto a cell. This can easily be adapted to paint numerous images, text excetera.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That means you adjust the picture width yourself, everytime you inserting a new bitmap, you adjust the width, append it to the right of the picture using draw functions, then you insert into the cell as image.