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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PushButton cell with image

Thread ID:





58710 Mar 27,2007 08:49 AM UTC Mar 28,2007 09:28 AM UTC WinForms 4
Tags: GridControl
Henning Möller
Asked On March 27, 2007 08:49 AM UTC

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...



Jeba S [Syncfusion]
Replied On 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\\windows\Grid.Windows\Samples\CustomCellTypes\ButtonEditCells\

Best Regards,

Henning Möller
Replied On 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.



Rajagopal [Syncfusion]
Replied On 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.


Henning Möller
Replied On 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.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon