We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PushButton cell with image

Hi again,

since my request posted yesterday is yet unanswered, I tried to figure some alternative way to handle my problem. My next choice was a PushButton cell. This seems to be pretty good a replacement for the former Control cell, and it seems that the GridControl can better handle those buttons.

But unfortunately, I came across some new problems right away. Is it true that there's no way other than providing a new CellModel, a new CellRenderer and eventually even a new CustomProperty to have a PushButton cell show a given image?

What are the ImageList and ImageIndex properties in the BaseStyle stand for? Why doesn't the PushButton cell use those to show an image?

I came across the Ellipsis cell but I cannot use that one right away, neither, since it only provides a fixed image which has to be an embedded resource. I need a cell where I can provide a variable Image.

Please help since this blocks my project for a considerable amout of hours already...

TIA,

HMoeller.

4 Replies

JS Jeba S Syncfusion Team March 27, 2007 09:37 AM UTC

Hi HMoeller,

Please refer to the KB article How do I have an image in a pushbutton cell?
and let us know if this helps.The sample derives the cellmodel and renderer from PushButtonCellModel and PushButtonCellRenderer to show the button having a bitmap.

If you have the latest version, please refer this browser sample and see it helps.
C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\windows\Grid.Windows\Samples\CustomCellTypes\ButtonEditCells\

Best Regards,
Jeba.


HM Henning Möller March 27, 2007 10:19 AM UTC

Thanks for your instant reply.

The provided sample is pretty much similar to the EllipsisCell sample I already evaluated. It looks promising, but I still need some way to have variable images drawn into the button rather than a fixed bitmap which has to be an embedded resource.

I'm currently using version 4.3 and since I have to release soon, I would like to stay with it for now.

TIA,

HMoeller.


RA Rajagopal Syncfusion Team March 28, 2007 01:12 AM UTC

Hi HMoeller,

You can handle the DrawCellButton event of the grid and draw the image there. In the event handler code, you can use e.Graphics.DrawImage to draw the bitmap and then set e.Cancel = true. If you want to have different images for various cells, then check for the e.RowIndex and e.ColIndex, if that points to the cell you wanted draw the image accordingly. Below is the code snippet.

void grid_DrawCellButton(object sender, GridDrawCellButtonEventArgs e)
{
if (e.Style.CellType == "PushButton")
{
e.Graphics.DrawImage( Image.FromFile(@"./../../bitmap1.bmp" ), e.Button.Bounds );
e.Style.CellAppearance = GridCellAppearance.Raised;
e.Cancel = true;
}
}

Let us know if you need any further assistance.
Thanks for using Syncfusion Products.

Regards,
Rajagopal


HM Henning Möller March 28, 2007 09:28 AM UTC

I've gone with the ImagePushButton sample, extended by the info classes from the EditButton sample where I stripped most of the custom properties other than Image and Enabled.

It's okay for me now. But IMHO, I consider some 500+ additional lines of code just to have a PushButton with a custom image not really acceptable. Especially because there are already various properties in the StyleInfo classes to specify ImageLists and ImageIndexes.

As a conclusion, I have to state that your components are capable of doing almost everything but without a comprehensive documentation or your personal assistance, the developers are likely to get lost.

Thanks for your assistance.

HMoeller.

Loader.
Live Chat Icon For mobile
Up arrow icon