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
3521
How to enter edit mode on a newly activated cell
posted

I have a requirement to make a grid used entirely for data entry.  Once the user tabs off the last cell of the last row, the grid needs to grow a new row where data entry can continue (they don't want an add row in the grid, they want the grid to take care of it).

I have been able to successfully add the row without a problem and I have been able to set the correct cell to be active.  However, I still have to click in the cell to continue the data edit and the users don't want to have to do this click action.  They want to just be able to keep on typing.  I will include the code snippet on how to add the blank row, but as I will point out by the screen shot, it doesn't take it all the way to entering edit mode.  Any ideas?

Private Sub CellExitedEditMode(sender As System.Object, e As Infragistics.Controls.Grids.ExitEditingCellEventArgs) Handles dgDataEntry.CellExitingEditMode

        Dim dgRow As Row = Nothing
        Dim dgRows As RowCollection = Nothing

        If Not e.Cell Is Nothing Then

            Select Case e.Cell.Column.Key.ToLower()

                Case "notes"

                    ' see if on the last row...
                    If e.Cell.Row.Index = Me.dgDataEntry.Rows.Count - 1 Then

                        dgRow = Me.dgDataEntry.Rows.CreateItem()

                        Me.dgDataEntry.Rows.Insert(e.Cell.Row.Index + 1, dgRow)

                        ' set the first cell in the newly added row to being edited
                        Me.dgDataEntry.Rows(Me.dgDataEntry.Rows.Count - 1).Cells(0).IsActive = True

                    Else

                       
                    End If

                Case Else

            End Select

        End If

    End Sub

 

Parents
  • 3521
    posted

    My screen shot didn't get posted...try again...

  • 3521
    posted in reply to Alan Jackson

     

    Another approach I have taken is to try and manually entereditmode for that activated cell once the active cell is changing, but it does a strange things with drawing a box around the contents of the added text and then not retaining the values entered...

        Private Sub dgDataEntry_ActiveCellChanging(sender As Object, e As Infragistics.Controls.Grids.ActiveCellChangingEventArgs) Handles dgDataEntry.ActiveCellChanging

            Dim c As Cell = Nothing

            If Me._blnRowAdded = True Then

                Me._blnRowAdded = False
                c = Me.dgDataEntry.Rows(Me.dgDataEntry.Rows.Count - 1).Cells(0)

                If Me.dgDataEntry.EnterEditMode(c) = False Then

                    MessageBox.Show("Could not place cell in edit mode")

                End If

            End If
        End Sub

     

Reply Children