I'm trying to catch the KeyUp event in textbox of a DataGrid. I'm
picking up the keydown and keypress events ok, but not keyup. Can
anyone see what is wrong with this code. I been fighting with this
for way too long.
Thanks a ton,
Gene H.
==================
Option Strict On
Option Explicit On
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class DataGridNoEditColumn
Inherits DataGridTextBoxColumn
Private mDGTBCNotifyShiftKey As delegateDGTBCNotifyShiftKey
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal DGTBCNotifyShiftKey As
delegateDGTBCNotifyShiftKey)
MyBase.New()
mDGTBCNotifyShiftKey = DGTBCNotifyShiftKey
AddHandler Me.TextBox.KeyDown, AddressOf HandleKeyDown
AddHandler Me.TextBox.KeyUp, AddressOf HandleKeyUp
AddHandler Me.TextBox.KeyPress, AddressOf HandleKeyPress
End Sub
Private Sub HandleKeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
Console.WriteLine("caught " & e.KeyData & " in keydown")
If e.Shift Then
Console.WriteLine("caught a shift in keydown")
mDGTBCNotifyShiftKey(True)
End If
End Sub
Private Sub HandleKeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
Console.WriteLine("caught " & e.KeyData & " in keyup")
If e.Shift Then
Console.WriteLine("caught a shift in keyup")
mDGTBCNotifyShiftKey(False)
End If
End Sub
Private Sub HandleKeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs)
Console.WriteLine("caught " & e.KeyChar.ToString & " in
keypress")
End Sub
Protected Overloads Overrides Sub Edit(ByVal source As
CurrencyManager, _
ByVal rowNum As Integer, ByVal bounds As Rectangle, _
ByVal readOnly1 As Boolean, ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
'do not allow the unbound cell to become active
If (Me.MappingName = "Name") Then
MyBase.Edit(source, rowNum, bounds, readOnly1,
instantText, cellIsVisible)
End If
End Sub
End Class