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.

How to add an image on an Pushbutton in a gridgrouping control?

Thread ID:

Created:

Updated:

Platform:

Replies:

77780 Nov 17,2008 09:11 AM Nov 19,2008 09:46 AM Windows Forms 1
loading
Tags: GridControl
Wim Gilbert
Asked On November 17, 2008 09:11 AM

How can I put an image to a button in the gridgrouping controle?


Rajadurai C [Syncfusion]
Replied On November 19, 2008 09:46 AM

Hi Wim,

Thanks for your interest in Syncfusion products.

To add an image over the pushbutton,
1)you need to create your own control by deriving GridPushButtonCellModel and GridPushButtonCellRenderer

2)Add an overridden method in class derived from GridCellButton and add this button cell to the CellModel of gridgroupingcontrol.

The overridden method is given below:

public override void Draw(Graphics g, int rowIndex, int colIndex, bool bActive, GridStyleInfo style)
{
base.Draw(g, rowIndex, colIndex, bActive, style);
// draw the button
bool hovering = IsHovering(rowIndex, colIndex);
bool mouseDown = IsMouseDown(rowIndex, colIndex);
bool disabled = !style.Clickable;
ButtonState buttonState = ButtonState.Normal;
if (disabled)
buttonState |= ButtonState.Inactive|ButtonState.Flat;
else if (!hovering && !mouseDown)
buttonState |= ButtonState.Flat;
Point ptOffset = Point.Empty;
if (mouseDown)
{
ptOffset = new Point(1, 1);
buttonState |= ButtonState.Pushed;
}
DrawButton(g, Bounds, buttonState, style);
string bitmapName = "Browse.bmp"; // make sure this is included in project and marked as "Embedded Resource"
iconPainter.PaintIcon(g, Bounds, ptOffset, bitmapName, Color.Blue);
}


This draws a bitmap over the button.

If you have dashboard please refer the browser sample in the following location.
\\Windows\\Grid.Windows\Samples\2.0\CustomCellTypes\CellButtons

that does the same.

Regards,
Rajadurai


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.

;