Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CellEnter event blues
Message
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 8.0
OS:
Vista
Network:
Windows XP
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01493921
Message ID:
01493933
Views:
59
>I have this routine that works fine for me :
>
>
>
>    Sub grdbase1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles GrdBase1.CellEnter
>        If GrdBase1.CurrentCell.ReadOnly = True Then
>            SendKeys.Send("{TAB}")
>            Exit Sub
>        End If
>        If GrdBase1.columnDisabled(e.ColumnIndex) = True Then
>            SendKeys.Send("{TAB}")
>            Exit Sub
>        End If
>    End Sub
>
>
>Now I wanted to move this logic to my grdbase (datagridviewbase), but the editor tells me that there is no such thing as a cellEnter event.
>
>What am I missing?
Public Class DataGridViewBase
    Inherits DataGridView

    'Either:
    Public Sub DataGridViewBase()
        AddHandler CellEnter, AddressOf CellEntered
    End Sub

    Protected Sub CellEntered(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
        Dim dgv As DataGridView = DirectCast(sender, DataGridView)
        If dgv.CurrentCell.ReadOnly Then

        End If
    End Sub

    'Or:

    Protected Overrides Sub OnCellEnter(ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
        If CurrentCell.ReadOnly Then

        End If
        'etc
        MyBase.OnCellEnter(e)
    End Sub
End Class
(Hope I got the VB syntax right.....)BTW the handler code could probably be simplified:
If CurrentCell.ReadOnly Or ColumnDisabled(e.ColumnIndex) Then
        SendKeys.Send("{TAB}")
 End If
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform