Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enter Key blues in datagrid
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Enter Key blues in datagrid
Environment versions
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01492264
Message ID:
01492264
Views:
118
See below how I handle the enter key in my grid base class. This approach does not seem to be compatible with e.cancel= false of the cellValidating event.

What gives?
    Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
        If keyData = Keys.Enter Then
            Dim col As Integer = Me.CurrentCell.ColumnIndex
            Dim row As Integer = Me.CurrentCell.RowIndex
            Do
gtoLoop:
                col += 1
                If col = (Me.Columns.Count) Then
                    col = 1
                    row += 1
                    Exit Do
                    If row = Me.Rows.Count Then
                        Me.DataSource.datasource.tables(Me.DataSource.datamember).rows.add()
                    End If
                End If
                If Me.Columns(col).Visible = False Then GoTo gtoLoop
                Exit Do
            Loop
            Me.CurrentCell = Me(col, row)
            Return True
        End If
        Return MyBase.ProcessDialogKey(keyData)
    End Function

    Protected Overloads Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
        If e.KeyData = Keys.Enter Then
            Dim col As Integer = Me.CurrentCell.ColumnIndex
            Dim row As Integer = Me.CurrentCell.RowIndex
            Do
gtoLoop:
                col += 1
                If col = (Me.Columns.Count) Then
                    col = 1
                    row += 1
                    If row = Me.Rows.Count Then
                        Me.DataSource.datasource.tables(Me.DataSource.datamember).rows.add()
                    End If
                    Exit Do
                End If
                If Me.Columns(col).Visible = False Then GoTo gtoLoop
                Exit Do
            Loop
            Me.CurrentCell = Me(col, row)

            e.Handled = True
        End If
        MyBase.OnKeyDown(e)
    End Sub

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Next
Reply
Map
View

Click here to load this message in the networking platform