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.
Unfortunately, activation email could not send to your email. Please try again.

Set single cell to read only

Thread ID:

Created:

Updated:

Platform:

Replies:

20176 Oct 12,2004 03:02 AM Oct 12,2004 03:39 AM Windows Forms 1
loading
Tags: Grouping
Administrator [Syncfusion]
Asked On October 12, 2004 03:02 AM

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

Administrator [Syncfusion]
Replied On October 12, 2004 03:39 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;