GridControl button backcolor

Hi,
Is it possible to change the backcolor of one button on a GridControl during an event?
I've read some posts on forum and found a way to change all the buttons backcolor using DrawCellButtonBackground but just want to change 1 button at time. Since the posts are from 2003/2004 is it possible already?
Thanks

3 Replies

SN Sindhu Nagarajan Syncfusion Team June 18, 2018 12:15 PM UTC

Hi Dinis, 

Thanks for using Syncfusion products. 

If you want to apply the back color for specific buttons, you can use the button indices or also you can use the display text of the specific button. Please refer to below code snippet and let us know if you have any other queries. 

Code Example 
//Event Triggering          
gridControl1.DrawCellButtonBackground += GridControl1_DrawCellButtonBackground; 
 
//Event Customization 
private void GridControl1_DrawCellButtonBackground(object sender, GridDrawCellButtonBackgroundEventArgs e) 
{ 
    if ((e.Style.CellIdentity.RowIndex == 7 && e.Style.CellIdentity.ColIndex == 3) 
        || e.Button.Text == "PB2") 
    { 
        e.Graphics.FillRectangle(new SolidBrush(Color.Red), e.Bounds); 
        e.Cancel = true; 
    }            
}        


Please let us know if you have any other queries. 

Regards, 
Sindhu  



DF Dinis Ferreira June 18, 2018 12:53 PM UTC

Hi Sindhu,

It works perfectly.

Thank you.


SN Sindhu Nagarajan Syncfusion Team June 19, 2018 04:15 AM UTC

Hi Dinis, 

Thanks for the update. 
We are glad to hear that the provided solution resolved your scenario. Please let us know if you have any other queries. 

Regards, 
Sindhu  


Loader.
Up arrow icon