How to make the cells into readonly in WinForms GridControl?
Set the cell into read-only
In WinForms GridControl, you can make the cell read-only by setting the ReadOnly Property in the GridModel or by using the QueryCellInfo Event.
Using GridModel
//particular cell is set to be ReadOnly
gridControl1[3, 3].BackColor = Color.Yellow;
gridControl1[3, 3].ReadOnly = true;
//Using GridRangeInfo, Range of cells is set to be ReadOnly
GridStyleInfo style = new GridStyleInfo();
style.ReadOnly = true;
style.BackColor = Color.Red;
this.gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 2, 2), style);
//Using GridRangeInfo,the row is set to be Readonly
style.BackColor = Color.Blue;
this.gridControl1.ChangeCells(GridRangeInfo.Row(4), style);
//Using GridRangeInfo, The Column is set to be Readonly
style.BackColor = Color.Aqua;
this.gridControl1.ChangeCells(GridRangeInfo.Col(4), style);'particular cell is set to be ReadOnly
gridControl1(3, 3).BackColor = Color.Yellow
gridControl1(3, 3).ReadOnly = True
'Using GridRangeInfo, Range of cells is set to be ReadOnly
Dim style As New GridStyleInfo()
style.ReadOnly = True
style.BackColor = Color.Red
Me.gridControl1.ChangeCells(GridRangeInfo.Cells(1, 1, 2, 2), style)
'Using GridRangeInfo,the row is set to be Readonly
style.BackColor = Color.Blue
Me.gridControl1.ChangeCells(GridRangeInfo.Row(4), style)
'Using GridRangeInfo, The Column is set to be Readonly
style.BackColor = Color.Aqua
Me.gridControl1.ChangeCells(GridRangeInfo.Col(4), style)Using QueryCellInfo
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
// particular cell is set to be ReadOnly
if (e.RowIndex == 3 && e.ColIndex == 3)
{
e.Style.BackColor = Color.Yellow;
e.Style.ReadOnly = true;
}
//Using GridRangeInfo,the row is set to be Readonly
if (e.RowIndex == 4)
{
e.Style.BackColor = Color.Blue;
e.Style.ReadOnly = true;
}
//Using GridRangeInfo, The Column is set to be Readonly
if (e.ColIndex == 4)
{
e.Style.BackColor = Color.Aqua;
e.Style.ReadOnly = true;
}
//Using GridRangeInfo, Range of cells is set to be ReadOnly
if ((e.RowIndex == 1 || e.RowIndex == 2) && (e.ColIndex == 1 || e.ColIndex == 2))
{
e.Style.BackColor = Color.Red;
e.Style.ReadOnly = true;
}
}Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
'particular cell is set to be ReadOnly
If e.RowIndex = 3 AndAlso e.ColIndex = 3 Then
e.Style.BackColor = Color.Yellow
e.Style.ReadOnly = True
End If
'Using GridRangeInfo,the row is set to be Readonly
If e.RowIndex = 4 Then
e.Style.BackColor = Color.Blue
e.Style.ReadOnly = True
End If
'Using GridRangeInfo, The Column is set to be Readonly
If e.ColIndex = 4 Then
e.Style.BackColor = Color.Aqua
e.Style.ReadOnly = True
End If
'Using GridRangeInfo, Range of cells is set to be ReadOnly
If (e.RowIndex = 1 OrElse e.RowIndex = 2) AndAlso (e.ColIndex = 1 OrElse e.ColIndex = 2) Then
e.Style.BackColor = Color.Red
e.Style.ReadOnly = True
End If
End Sub The following
screenshot displays the grid after applying the properties.

Figure 1: Make the cells into ReadOnly
Note:
The read-only cells are shown in different colors.
Samples:
C#: ReadOnlyCells
VB: ReadOnlyCells
Conclusion
I hope you enjoyed learning about how to make the cells into read-only in the WinForms GridControl.
You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!