Hi,
I'm trying to catch the KeyPress event in a datagridviewcell.
Here is some code:
The InitializeComponent of CommonDataGridViewTextBoxColumn:
In my datagridview I set the columntype to CommonDataGridViewTextBoxColumn ... but when I press a key in the cell the keypress isn't fired.
Thanks in advance for any help.
I'm trying to catch the KeyPress event in a datagridviewcell.
Here is some code:
VB.NET:
Public Class CommonDataGridViewTextBoxColumn
Inherits DataGridViewTextBoxColumn
Private _uppercase As Boolean
Public Property Uppercase() As Boolean
Get
Return _uppercase
End Get
Set(ByVal value As Boolean)
_uppercase = value
End Set
End Property
End Class
Public Class CommonDataGridViewTextBoxCell
Inherits DataGridViewTextBoxCell
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs, ByVal rowIndex As Integer)
MyBase.OnKeyPress(e, rowIndex)
If CType(Me.OwningColumn, CommonDataGridViewTextBoxColumn).Uppercase Then
e.KeyChar = Char.ToUpper(e.KeyChar, My.Computer.Info.InstalledUICulture)
End If
End Sub
End Class
VB.NET:
Me.CellTemplate = New CommonDataGridViewTextBoxCell
Thanks in advance for any help.