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

Turn off CellButton hover-color

I have a GridControl which embeds CellButtons like one of the demo apps.

But I want the button to remain the same color, and only change when its pressed.

At the moment the button changes color when the mouse hovers over it, which doesnt look nice.

Id like to still use themes, but if this isnt possible Id rather just render the button myself

Thanks


1 Reply

AD Administrator Syncfusion Team March 31, 2008 11:17 PM UTC

HiCarpii,

Thank you for your interest in Syncfusion products.

You need to override Draw method of GridCellButton class and set the hovering to false to prevent drawing of the cell button when hovering the cell. Please refer the code below for more details.

public override void Draw(Graphics g, int rowIndex, int colIndex, bool bActive, GridStyleInfo style)
{
TraceUtil.TraceCurrentMethodInfo(rowIndex, colIndex, bActive, style.CellValue);
base.Draw(g, rowIndex, colIndex, bActive, style);
bool hovering = false;/// 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);
}


Here is the minimal sample that implement this task.
http://websamples.syncfusion.com/samples/Grid.Windows/F72640/main.htm

Please let me know if this helps.

Best Regards,
Srirajan



Loader.
Live Chat Icon For mobile
Up arrow icon