Override the IsInputKey method to get arrow keys fire keypress event as
such:
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Up OrElse keyData = Keys.Down OrElse _
keyData = Keys.Right OrElse keyData = Keys.Left OrElse _
keyData = Keys.Enter Then
Return True
End If
End Function
Bruce D expressed precisely :
> I have a datagrid (uggg) that I use and create the columns
> programmatically...see below.
> objCol = New DataGridTextBoxColumn
> objCol.MappingName = "amount"
> objCol.HeaderText = "Amount"
> objCol.Width = 60
> objCol.Format = "C"
> objDGTS.GridColumnStyles.Add(objCol)
> ' create keypress, validating events for this textbox column only
> Dim dgtb As DataGridTextBox = CType(objCol.TextBox,
> DataGridTextBox)
> AddHandler dgtb.KeyPress, AddressOf Amount_KeyPress
> AddHandler dgtb.Validating, AddressOf Amount_Validating
> Everything seems to work great...except that the event "Amount_Validating"
> does not fire when I use the "arrow keys" or the "enter key". It fires
> when
> I use the "tab key" or use the mouse to click aournd on the grid. I'm
> assuming this has something to do with "focus" or something like that.
> Can anyone help me get this event to fire with the enter key/arrow keys?
>
> TIA
> -bruce duncan
--
--------------------------------------------------
Christopher C. Bernholt
I.T. Research & Development
..NET Re-Engineering Team
R & L Carriers, Inc.
http://www.gorlc.com
--------------------------------------------------