Set single cell to read only

I have 2 cells for user to edit If not Cell_1 is nothing then ''set Cell_2 to read only end if May I know how can I set Cell_2 to read only ? Thanks

1 Reply

AD Administrator Syncfusion Team October 12, 2004 07:39 AM UTC

You can try handling the QueryCellStyleInfo event.
Private Sub GridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs) Handles GridGroupingControl1.QueryCellStyleInfo
        ''make "Col1" readonly if "Col0" is the not the empty string
        If Not (e.TableCellIdentity.Column Is Nothing) AndAlso e.TableCellIdentity.Column.Name = "Col1" Then
            If e.TableCellIdentity.DisplayElement.GetType() Is GetType(GridRecordRow) Then

                Dim rec As GridRecordRow = e.TableCellIdentity.DisplayElement
                Dim o1 As Object = rec.GetData()
                If Not o1 Is Nothing AndAlso o1.GetType() Is GetType(DataRowView) Then
                    Dim drv As DataRowView = o1
                    Dim o As Object = drv("Col0")
                    If Not (o Is Nothing) And o.ToString().Length > 0 Then
                        e.Style.ReadOnly = True
                        e.Style.BackColor = Color.LightGoldenrodYellow
                    End If
                End If
            End If

        End If
    End Sub

Loader.
Up arrow icon