You can lock individual grid cells by using the FetchCellStyle event. To lock the value in cell (1, 0):
1. Set the FetchStyle property of the column containing the cell to True.
In the Designer
· Open the TrueDBGrid Designer. For information on how to access the TrueDBGrid Designer, see Accessing the TrueDBGrid Designer.
· Select the First column by clicking on it in the right pane.
Alternatively, it can also be selected from the drop-down list in the toolbar.
· Click the Display Columns tab in the left pane.
· Set the FetchStyle property to True.
· Click OK to close the designer.
In Code
Add the following code to the Form_Load event:
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0).FetchStyle = True
· C#
this.c1TrueDBGrid1.Splits[0].DisplayColumns[0].FetchStyle = true;
· Delphi
Self.C1TrueDBGrid1.Splits[0].DisplayColumns[0].FetchStyle := true;
2. Set the Locked property of the CellStyle object to True only for the value in row one:
Private Sub C1TrueDBGrid1_FetchCellStyle(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs) Handles C1TrueDBGrid1.FetchCellStyle
If e.Row = 1 Then
e.CellStyle.Locked = True
End If
End Sub
· C#
private void C1TrueDBGrid1_FetchCellStyle(object sender, C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs e)
{
if (e.Row == 1)
{
e.CellStyle.Locked = true;
}
}
· Delphi
Procedure TForm1.C1TrueDBGrid1_FetchCellStyle(sender: object; e: C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs);
begin
if (e.Row = 1) then
begin
e.CellStyle.Locked := true;
end;
end;
This topic illustrates the following:
The value in the cell (1, 0) cannot be edited.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |