> > 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 >>
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