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
Detecting CellExitedEditMode from ButtonPress Event?
posted

I have a XamGrid with a requirement to be able to move between cells with either a tab key or enter key.  The reason is that it is highly data entry intensive and the folks doing the data entry want to minimize usage of mouse and tab keys.  If they could, they would like to stay within the number pad area of the keyboard.

Consequently, I have to aid the navigation from cell to cell, and even skip over appropriate cells.  Therefore, I am processing the CellExitedEditMode event, and based on the cell exiting, I am throwing you into edit mode into the next logical cell.  Without this logic, the enter key would never advance the editing function.

There is a bad side effect however.  When you click on a button to commit changes, the grid is still in edit mode.  And based on the logic of how I have to navigate you around, you will basically never leave edit mode on this grid.  So the button event never fires.  That is unless in the CellExitedEditMode event, I can find out the source of the event and see if it is a button and then exit the edit mode of the grid.

For reference, I have included the code I am using in this event, to give you a flavor of what is going on.  Unfortunately, this code is being hit on button press, and it is in effect cancelling the button click event.  Any advice would be appreciated.

The bottom line is that I would like to be able to know in the cellexiteditmode event that I am exiting as a result of a button click.  I guess alternatively, I could try and do a "client event" on the button to kick the grid out of edit mode?  Don't know if this is possible in Silverlight.

 

    Private Sub dgDataEntry_CellExitedEditMode(sender As Object, e As Infragistics.Controls.Grids.CellExitedEditingEventArgs) Handles dgDataEntry.CellExitedEditMode

        Dim dgRow As Row = Nothing
        Dim c As Cell = Nothing

        If Not e.Cell Is Nothing Then

            Me._intDataEntryIndex = e.Cell.Row.Index

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

                Case "projid"

                    If Not e.Cell.Value Is Nothing AndAlso e.Cell.Value <> String.Empty Then
                        Me._proxyCR.SFProjectNameAsync(CType(e.Cell.Value, String), New SFCallResult())
                    End If

                    c = Me.dgDataEntry.Rows(Me._intDataEntryIndex).Cells(2)

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

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

                    End If

                    Me.dgDataEntry.EnterEditMode()

                Case "orgabbrvcd"

                    If Not e.Cell.Value Is Nothing AndAlso e.Cell.Value <> String.Empty Then
                        Me._proxyCR.SFValidOrgAsync(CType(e.Cell.Value, String), New SFCallResult())
                    End If

                    c = Me.dgDataEntry.Rows(Me._intDataEntryIndex).Cells(3)

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

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

                    End If

                    Me.dgDataEntry.EnterEditMode()

                Case "glacctid"

                    Dim f As SFDetailItem = CType(e.Cell.Row.Data, SFDetailItem)

                    If Not f.GLAcctId Is Nothing AndAlso f.GLAcctId <> String.Empty Then
                        Me._proxyCR.SFValidAcctAsync(f.ProjId, f.GLAcctId, New SFCallResult())
                    End If

                    c = Me.dgDataEntry.Rows(Me._intDataEntryIndex).Cells(4)

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

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

                    End If

                    Me.dgDataEntry.EnterEditMode()

                Case "qty"

                    c = Me.dgDataEntry.Rows(Me._intDataEntryIndex).Cells(5)

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

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

                    End If

                    Me.dgDataEntry.EnterEditMode()

                Case "price"

                    c = Me.dgDataEntry.Rows(Me._intDataEntryIndex).Cells(7)

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

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

                    End If

                    Me.dgDataEntry.EnterEditMode()


            End Select

        End If

    End Sub