Setting A Pushbutton Cell''s Color & Font
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
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
December 4, 2004 12:29 PM UTC
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.
JB
John Bowm
December 4, 2004 02:05 PM UTC
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
AD
Administrator
Syncfusion Team
December 5, 2004 10:01 PM UTC
Another way you can do this is to handle the DrawCellButtonBackground event. Here is a sample.
ColoredButtons_1634.zip
JB
John Bowm
December 7, 2004 07:32 PM UTC
Clay,
Thanks again for the example code. It may just work out better for the way we need it to behave.
John
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
JB John Bowm
- Dec 4, 2004 11:23 AM UTC
- Dec 7, 2004 07:32 PM UTC