470,596 Members | 1,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Can't Catch KeyUp Event

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
Nov 20 '05 #1
0 1291

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by JPSutor | last post: by
2 posts views Thread by Adam J. Schaff | last post: by
4 posts views Thread by ShaneO | last post: by
1 post views Thread by Frank O'Hara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.