Sie sind auf Seite 1von 1

[VB.

NET]
Public Class MyTextBox
Inherits TextBox
Private WM_KEYUP As Integer = &H101

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)


If m.Msg = WM_KEYUP Then
Return 'ignore the keyup
End If
MyBase.WndProc(m)
End Sub 'WndProc
End Class 'MyTextBox

5.91 How can I detect when a cell starts being edited, not when it
becomes current?
You can use the CurrentCellChanged event to detect when the currentcell changes position. But
this event will not allow you to catch the start of a cell being edited.

One way you can do this is to catch the TextChanged event in the embedded TextBox within the
cell. If the text changes, then it might be the beginning of a cell edit provided the text in the
TextBox differs from the stored value from the DataSource. The reason you need to check for a
different value between the grid DataSource and the TextBox contents is that the TextChanged
event is fired initially when the TextBox is initialized when the cell becomes current and moves
the value from the grid ataSource to the TextBox. You also have to ignore subsequent hits of
TextChanged as the same cell continues to be edited. Here is both a VB and C# sample that
implements this strategy to flagged current cell start editing.

Das könnte Ihnen auch gefallen