|
-
Jun 3rd, 2005, 03:03 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] how to bridge special key press from datagrid to form (resolved)
Dear all,
i have a form, i want to give it some hot keys functionality, so i did the following :
1 - i set the keypreview of the form to true
2 - in the keyup event i set a select case based on the e.keycode , like this
VB Code:
select case e.keycode
case 112
'save code
case 113
'delete code
case 114
'add new code
end select
it works fine, but !!!!!
when i have a datagrid on the form, and the focus is on the grid none of these hotkeys triggers anything.
when i move the focus to any other control on the form , the hot keys works well. i think the datagrid blocks the key strokes inside it assuming that i am editing inside its cells.
what i need now is to alter the keyup event on the datagrid and check if any of the keys i want (hot keys) is pressed , then i want to send the same keys to the form itself.
i don't want to activite my subs directly from the grid, i just want to bridge the keys from the grid to the form, and let the form handle it.
why want i do that in specific, because this is the base form of a project and during inheriting i may have different forms responding deifferently from each other.
Can i pass some special keys from the grid to the form (F1, F2 etc...), and How ????
thx in advance
RGDS
Last edited by maged; Jun 5th, 2005 at 02:53 PM.
-
Jun 3rd, 2005, 06:11 PM
#2
-
Jun 3rd, 2005, 08:21 PM
#3
Thread Starter
Frenzied Member
Re: how to bridge special key press from datagrid to form
i have tried linking both the datagrid and the form keyup events to the same handler without no hope.
while i was trying i figured that the datagrid doesn't feel anything when typing within it's cells. even when i wrote i single line inside the ky up event like
it didn't execute, only when the datagrid was empty with no cells at all, it felts the key up event. i want to trigger the key up event while editing inside each cell
how can i do this, or how can i make the datagrid cell echos the keyup events to the form for processing.
thx for your time
-
Jun 3rd, 2005, 09:45 PM
#4
Thread Starter
Frenzied Member
Re: how to bridge special key press from datagrid to form
-
Jun 4th, 2005, 08:40 PM
#5
New Member
Re: how to bridge special key press from datagrid to form
Hola amigo(a), I suffered to reach this conclusion , i hope this helps you (my english not is good):
1.- Fisrt create a class and copy this
VB Code:
Public Class MyDataGrid
Inherits DataGrid
Public Event MyKeyDown(ByVal KeyCode As Keys)
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
RaiseEvent MyKeyDown(keyData)
End Function
End Class
2.-Ready.. only create a single grid and the region code to the form change this:
VB Code:
Friend WithEvents Grid As DataGrid
For this :
VB Code:
Friend WithEvents Grid As MyDataGrid
3.-Finally you can doit the new method MyKeyDown(This event catch all keys )
VB Code:
Private Sub Grid_MyKeyDown(ByVal KeyCode As System.Windows.Forms.Keys) Handles Grid.MyKeyDown
Select Case KeyCode
Case Keys.F8
.............
Case Keys.F2
..............
Case Keys.Return
..............
End Sub
-
Jun 5th, 2005, 04:25 AM
#6
Thread Starter
Frenzied Member
Re: how to bridge special key press from datagrid to form
thx a million for your reply,
i will give it a try and i pray it will work,
if this works fine for me, believe me i will be thankfull for a long time.
RGDS
-
Jun 5th, 2005, 04:36 AM
#7
Thread Starter
Frenzied Member
-
Jun 5th, 2005, 11:04 AM
#8
New Member
Re: how to bridge special key press from datagrid to form
Not problem ,
Now, only mark your post with (Resolved)
Saludos desde México !
Last edited by jorgegc; Jun 11th, 2005 at 11:53 AM.
-
Aug 22nd, 2005, 11:04 PM
#9
Addicted Member
Re: [RESOLVED] how to bridge special key press from datagrid to form (resolved)
It really works like HELL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|