Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1165
Set focus on first non-read-only cell in a row
posted

I have a grid where the first column is read-only and the remaining cells are editable.

I have tabbing set to NextCell.  What I want is for a user to be able to tab into a new row and have focus set to the first editable cell in edit mode.

The following code works when I insert a stopper in the beginning of the event and step through; however, without the stopper it works, but then returns focus to the first cell in the row, causing a flicker, plus not doing what I want.

 Private Sub grdAccountSettings_AfterRowActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdAccountSettings.AfterRowActivate
        Try
            If Not _OnInit Then
                If grdAccountSettings.ActiveRow.Index > 0 And (grdAccountSettings.ActiveCell Is Nothing OrElse grdAccountSettings.ActiveCell.Column.Index = 0) Then
                    grdAccountSettings.ActiveRow.Cells(1).Activate()
                    grdAccountSettings.PerformAction(UltraGridAction.EnterEditMode, False, False)
                End If
            End If
        Catch ex As Exception
            Debug.Write(ex.Message)
        End Try
    End Sub

Parents
No Data
Reply
  • 1165
    posted

    Actually, please excuse the code in my previous post.  Here is the code I am dealing with.  The problem is the same - there is currently no code in my AfterRowActivate event; however, if a put a stopper in the second If/Then of my GotFocus event, I get the correct behavior.

     

     Private Sub grdAccountSettings_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdAccountSettings.GotFocus
            Try
                If Not _OnInit Then
                    'AF 9/17/2010
                    If grdAccountSettings.ActiveRow IsNot Nothing AndAlso (grdAccountSettings.ActiveCell Is Nothing OrElse grdAccountSettings.ActiveCell.Column.Index = 0) Then
                        grdAccountSettings.ActiveRow.Cells(1).Activate()
                        grdAccountSettings.PerformAction(UltraGridAction.EnterEditMode, False, False)
                        If Not grdAccountSettings.Focused AndAlso grdAccountSettings.ActiveCell IsNot Nothing Then
                            Dim elem As UIElement = grdAccountSettings.ActiveCell.GetUIElement
                            Dim embeddableElement As EmbeddableUIElementBase = TryCast(elem.GetDescendant(GetType(EmbeddableUIElementBase)), EmbeddableUIElementBase)
                            grdAccountSettings.ActiveCell.EditorResolved.EnterEditMode(embeddableElement)
                        End If
                    End If
                    ' grdAccountSettings.DisplayLayout.Override.ActiveAppearancesEnabled = DefaultableBoolean.True
                End If

            Catch ex As Exception
                MessageBox.Show(MessageBox.Show(MyBase.LogError(ex)))
            End Try
        End Sub 

Children