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.

Setting A Pushbutton Cell''s Color & Font

Thread ID:

Created:

Updated:

Platform:

Replies:

22142 Dec 4,2004 06:23 AM Dec 7,2004 02:32 PM Windows Forms 4
loading
Tags: GridControl
John Bowm
Asked On December 4, 2004 06:23 AM

Hi, If I have a grid control that has a cell whose cell type is pushbutton, how do I set the color of the button''s background (& it''s font for that matter)? I tried using: MyGrid[r,c].CellType = PushButton; MyGridr,c].CellAppearance = GridCellAppearance.Raised; GridStyleInfo gsi = new GridStyleInfo(); gsi.BackColor = Color.AliceBlue; MyGrid[r,c].ChangeCells(GridRangeInfo(r,c), gsi); But this approach seems to be ignored. the button is always grey. Any ideas? TIA, John

Administrator [Syncfusion]
Replied On December 4, 2004 07:29 AM

Our PushButton uses ControlPaint.DrawButton to draw the button, and this method does not support background coloring (other than what you might get from a Themed OS.). So, for now, there is no property setting that you can use to handle this. Some ways around this would be to add a Windows Forms PushButton (which does accept a backcolor) to a cell using the Control celltype. This would only be useful if you had 1 or 2 cells where you wanted to see this button. Here is a little sample. If you needed to have this button in a lot of cells, you would have to derive a custom button to handle this. You could either do a bitmap button like the one shown in grid\samples\in depth\cellbuttons or you could derive a cell control like the grid\samples\cellstypes\calendarcell but using a Windows Forms PushButton instead of the calendar.

John Bowm
Replied On December 4, 2004 09:05 AM

Clay, Thanks for the help/ideas (btw, why are you answering this on Sat? ). I''ve been trying to work w/ the CellButtons example, but not yet able to customize it to what I''d like and make it work. I may just not waste any time and live w/ the std grey color on the built in PushButton type because I don''t have much time to iron this out. John

Administrator [Syncfusion]
Replied On December 5, 2004 05:01 PM

Another way you can do this is to handle the DrawCellButtonBackground event. Here is a sample. ColoredButtons_1634.zip

John Bowm
Replied On December 7, 2004 02:32 PM

Clay, Thanks again for the example code. It may just work out better for the way we need it to behave. John

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.

;