Link to home
Start Free TrialLog in
Avatar of JamesAStewart
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(string1,string2,string3,bitmaps,string4,string5)

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
Avatar of adriankohws
adriankohws
Flag of Singapore image

I don't think is possible unless, you draw a picture yourself before inserting into the cell.
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.
Avatar of JamesAStewart
JamesAStewart

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.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial