Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Difference between a functionkey and a pushbutton
Message
 
À
12/07/2000 06:32:34
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00389333
Message ID:
00391136
Vues:
15
>>>>>On my form everything is disabled and it holds a datagrid, keypreview is true.
>>>>>When I press a functionkey the datagrid has to be enabled, the current row has to be highlighted and when I press the down arrow key I have to scroll in the grid.
>>>>>This code written under the functionkey doesn’t work, when I put the same code under a pushbutton it works.
>>>>>Code:
>>>>>With dgdgrid
>>>>>.Enabled = True
>>>>>.MarqueeStyle = 3
>>>>>.SetFocus
>>>>>End With
>>>>>
>>>>>Can someone please tell me why it doesn’t work under a functionkey and what the solution is?
>>>>
>>>>What do you mean by "functionkey"? Is it F1 and the rest? Where do you place it to it isn't working? I suppose that you have placed it in the Form_KeyDown event!
>>>>
>>>>Show more code!!!
>>>
>>>Yes, you are correct I do mean F1 and the rest, and placed the code for capture in the Form_KeyDown event.
>>>With a Case I check all keys and call Private Subs.
>>>When F10 is pressed I call a Private Sub to delete a row in the grid. The grid is disabled. The Private sub contains the code above, the RecordSet is also opened in this sub.
>>>The code for deleting the row is a different Private Sub, called when the "Enter" key is pressed.
>>>
>>>When F10 is pressed, the grid in enabled, the current row is highlighted but when pressing the "Down Arrow" key the form menu (top left) scrolls down and I'm scrolling in that menu instead of in the grid.
>>>As I mentioned before that same code under a pushbutton works.
>>>
>>>I hope you can clear this for me, thank you.
>>
>>I have done a small test. Here is my code:
>>
>>Option Explicit
>>
>>Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
>>Select Case KeyCode
>>    Case vbKeyF1
>>        MsgBox "F1 pressed!"
>>    Case vbKeyF10
>>        MsgBox "F10 pressed!"
>>End Select
>>End Sub
>>
>>
>>On my form, I had a command button, a ADO data control and a datagrid. When the grid has focus, I can only see F10 message box. When other control have focus, I can see both F1 and F10. It seems that the grid intercept this key.
>>
>>I suggest that you used another key because F1 is normaly associated to help!
>
>I'm sorry, but this is not exactly what I mean.
>My code in the Form_KeyDown event is simular to yours:
>
>Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
>Select Case KeyCode
> Case vbKeyF10:
> Call DeleteRow 'Call of a Private Sub
>End Select
>End Sub
>
>The Private sub contains:
>
>With dgdgrid
> .Enabled = True
> .MarqueeStyle = 3
> .SetFocus
>End With
>
>The problem is when I push the "Down Arrow" key I want to scroll in the grid to select a row to delete.
>But with this code, when I press the "Down Arrow" key I'm scrolling the main Form menu (Top left) instead of the grid. I thought, when the grid is enabled and it has the focus I would normally scroll in it but that is just the problem.
>
>I hope this is more clear for you, thank you.
dgdgrid.setfocus
doevents
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform