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

Set single cell to read only

Thread ID:





20176 Oct 12,2004 07:02 AM UTC Oct 12,2004 07:39 AM UTC WinForms 1
Tags: Grouping
Administrator [Syncfusion]
Asked On October 12, 2004 07:02 AM UTC

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 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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon