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
close icon

How can I change background color of the clicked row

I need to change background color of entire row in GridGroupingControl when user clicks on any cell in that row.

Tried to do that in TableControlCellClick event, but have no idea how to do that... :(


3 Replies

HA haneefm Syncfusion Team April 27, 2007 09:08 PM UTC

Hi Jiri,

You can try this code.

gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;
gridGroupingControl1.TableOptions.SelectionBackColor = Color.Red;

Best regards,
Haneef


KB Karsten Brocksieper June 26, 2008 09:52 AM UTC

Hello,

this works really good.

I have one more question regarding this issue. With this code the clicked row change the backcolor --- but not the clicked cell. The backcolor of the clicked cell don´t change.
Is it possible to change the color of the clicked cell too?

Regards,
Karsten





JJ Jisha Joy Syncfusion Team June 27, 2008 10:34 AM UTC

Hi Karsten,

This can be achieved by handling the QueryCellStyleInfo event. Please refer the code:



void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if (e.TableCellIdentity.RowIndex == cc.RowIndex && e.TableCellIdentity.ColIndex == cc.ColIndex)
{

e.Style.BackColor = this.gridGroupingControl1.TableOptions.SelectionBackColor;
this.gridGroupingControl1.TableControl.RefreshRange(GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex));

}
}



Regards,
Jis


Loader.
Live Chat Icon For mobile
Up arrow icon