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

Setting the color and non-editable properties of a specific row in Grid

In SyncDatagrid 1.I'm unable to set the backcolor for a specific row/cell in spite of trying the rowstyles and other backcolor properties . 2.I'm unable to set a row/cell read-only .

1 Reply

AD Administrator Syncfusion Team May 3, 2003 07:13 PM UTC

In a GridDataBoundGrid, you cannot set rowstyles or individual cellstyles as there is storage allcoated for such object. In a GridControl, you can use rowstyles and set individual cell styles. In a GridDataBoundGrid, you can set styles for rows or individual cells by handling the PrepareViewStyleInfo event. In it, if e.RowIndex points to the row want was to set teh styles on, and if e.ColIndex > 0, then set e.Style with the properties you want to use. You can also set individual cells readonly in PrepareViewStyleInfo.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	//only check interior cells
	if(e.ColIndex > 0 && e.RowIndex > 0)
		if(e.RowIndex % 3 == 0 )
                     e.Style.BackColor = Color.Teal;

Live Chat Icon For mobile
Up arrow icon