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 to Change Border of Selected Row

I have a GridControl where I''ve set the SelectionMode to ''None'' and the ListboxSelectionMode to ''One''. How might I go about drawing a bolder border around the selected row instead of changing the background color of the selected row? That is, I would like the selected row to look the same as an unselected row in every way except that the selected row would have a thicker border around it to make it stand out.

2 Replies

AD Administrator Syncfusion Team May 18, 2006 03:54 AM UTC

Hi Don, Colud you try this code to change the border of the selected rows in a grid using PrepareViewStyleInfo event. Here is a code snippet in C#.Net. //Form''s Load Event this.gridControl1.ListBoxSelectionMode = SelectionMode.One; this.gridControl1.AlphaBlendSelectionColor = Color.PaleVioletRed; GridRangeInfoList Rows = null; private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { Rows = this.gridControl1.Model.Selections.GetSelectedRows(true,false); if(e.ColIndex > 0 && Rows != null && Rows.AnyRangeIntersects(GridRangeInfo.Row(e.RowIndex ))) { e.Style.Borders.Top = new GridBorder(GridBorderStyle.Solid,Color.Red,GridBorderWeight.ExtraThick); e.Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid,Color.Red,GridBorderWeight.ExtraThick); if(e.ColIndex == 1) { e.Style.Borders.Left = new GridBorder(GridBorderStyle.Solid,Color.Red,GridBorderWeight.ExtraThick); } else if(e.ColIndex == this.gridControl1.RowCount) { e.Style.Borders.Right = new GridBorder(GridBorderStyle.Solid,Color.Red,GridBorderWeight.ExtraThick); } } } Here is a sample. http://www.syncfusion.com/Support/user/uploads/GridSelectionBorder_e94f6412.zip Please let me know if this helps. Best Regards, Haneef


MS Maxim Software Systems May 18, 2006 02:04 PM UTC

The code you provided works (with one correction on the second last line - RowCount should be ColCount). Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon