Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
System.Windows.Forms.DataGrid Does Not Raise KeyDown Event When Tab, Enter, or Arrow Keys Are Pressed
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.controls.


Chad Boschert
I am trying to change the behavior of the enter key within a DataGrid.
The default behavior drops the cursor to the next row - I want the
cursor to go to the next cell (just like the tab key.)

I have my event handler wired up to the KeyDown event of the
DataGridTextBox controls in my DataGrid. The event gets raised for
all keys accept the Tab, Enter, and Arrow Keys.

Any ideas as to how this can be accomplished?

-Chad Boschert
Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Stephen Alpert
On 1 Jul 2003 08:30:02 -0700, Click here to reveal e-mail address (Chad Boschert) wrote:

[Original message clipped]

Chad: Those keys are normally form navigation keys and that's why you don't see
them. I don't have the answer to your question..

/steveA
my email Click here to reveal e-mail address is encrypted with ROT13 (www.rot13.org)
Reply to this message...
Vote that this is a GOOD answer...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
walter leinert
Hi Chad,

may be that you must set the AcceptsReturn property of the DataGridTextBox
to receive the event.

Walter

"Chad Boschert" <Click here to reveal e-mail address> schrieb im Newsbeitrag
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Chad Boschert
Walter, that is a good idea but still doesn't seem to work. If I
enable the acceptstab property the event is raised for the tab key;
I'm not sure what is happening. I also tried enabling the multiline
property - no luck.

- Chad
Reply to this message...
Vote that this is a GOOD answer...
 
Email Archiving and Email Filing - what’s the difference?
Web-based task/todo list management
 
    
Brendon Webber
What you need to do is actually capture the windows message and then process that event accordingly. Here is an example where the ProcessCmdKey method is overidden in a customised ComboBox class. Create a custom DataGrid class and override this method.

Hope this helps...

Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Dim bHandled As Boolean = False

Try

If bIsReadOnly Then
Return True
End If

If ((keyData = (Keys.Tab Or Keys.Shift)) And (Me.ModifierKeys = Keys.Shift)) Or (keyData = Keys.Left) Then
Return MyBase.ProcessCmdKey(msg, keyData)
ElseIf (keyData = Keys.Tab) Or (keyData = Keys.Enter) Or (keyData = Keys.Return) Then

msg.Result = IntPtr.Zero
If keyData = Keys.Tab Then
Dim e As New FocusChangeEventArgs(FocusDirection.Forward)
RaiseEvent LostFocus(Me, e)
If e.Handled Then
Return True
Else
Return MyBase.ProcessCmdKey(msg, keyData)
End If
Else
System.Windows.Forms.SendKeys.Send(Chr(9))
Return True
End If

Else
Return MyBase.ProcessCmdKey(msg, keyData)
End If

Catch ex As Exception
MsgBox(ex, , "Library > SComboBox > ProcessCmdKey")
End Try

End Function

--------------------------------
From: Brendon Webber
Reply to this message...
Vote that this is a GOOD answer...
 
Open source windows
The Law Society’s guidelines on e-mail management
 
 
System.IntPtr
System.Web.UI.WebControls.DataGrid
System.Windows.Forms.ComboBox
System.Windows.Forms.DataGrid
System.Windows.Forms.DataGridTextBox
System.Windows.Forms.Keys
System.Windows.Forms.Message
System.Windows.Forms.SendKeys




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734