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.
Unfortunately, activation email could not send to your email. Please try again.

PushButton cell with image

Thread ID:

Created:

Updated:

Platform:

Replies:

58710 Mar 27,2007 04:49 AM Mar 28,2007 05:28 AM Windows Forms 4
loading
Tags: GridControl
Henning Möller
Asked On March 27, 2007 04:49 AM

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.

Jeba S [Syncfusion]
Replied On March 27, 2007 05:37 AM

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.

Henning Möller
Replied On March 27, 2007 06:19 AM

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.

Rajagopal [Syncfusion]
Replied On March 27, 2007 09:12 PM

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

Henning Möller
Replied On March 28, 2007 05:28 AM

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.

CONFIRMATION

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.

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.

;