I would like to use a bar graph as my cell display for one of my grid columns. It would be very small I know, but it would only have a few bars of data. It's about the 'feel of the graph curve' more than the actual numbers associated with the graph values.
What is the best way to accomplish this?
Thanks.
Your best bet is likely to use a style of Image in your column and use an image of the graph as the cell's value. I don't think that there's an easy way of embedding an UltraChart into a grid cell, though I could be mistaken.
-Matt
I don't really wanna generate an image for every row, worried about speed I guess...
If I have written a custom UserControl which uses textboxes as graph bars, can I attach that somehow to the cell? Like EditorControl?
No, you cannot embed a UserControl in a cell unless it implements IProvidesEmbeddableEditor, which is not an easy feat. I believe that some people on the forums have posted a way to accomplish this, so you might want to try searching the forums.
If you're worried about performance, though, I'm not quite sure how embedding the control in the row would be any faster, since the control itself would still have to perform its layout logic and then paint into the requisite area, and do this every time there is a resize/invalidation/etc. If you do this with an image, it only has to do this logic once and then afterwards the only expense is the rendering of an image (and of course the memory footprint of the image).
I got this working by creating my own image by creating a Bitmap and drawing the graph using Graphics & Rectangles ie.
Bitmap myBitmap = new Bitmap(totalWidth, totalHeight); Graphics myG = Graphics.FromImage(myBitmap);
etc...
I then assign the bmp to the background cell image. Because my graph is so simple, it was very easy to write. Seems quite fast.
Not sure bitmap is the best option, but it's all I could find. Is there a better choice for memory usage?
I image that generating 1000 images would be pretty slow. But you would only have to generate each images once, so the performance hit would all be up-front.
Another option that might work better for you would be to generate the images only when the cell paints. You would do this using a DrawFilter. The advantage of this is that you would only have a few images visible at any one time, so it would save memory. The down side is that the image would need to be regenerated every time the cell paints, so that would probably be worse - unless you can cache the image and re-use it. If you can track when the data that affects the chart changes and thus know that the image needs to be regenerated, then that would probably be the most efficient approach.
Perhaps...it's just such a simple graph.
I wonder how fast the full Infragistics charting engine can produce images for a 1000 rows...hmmmm