Read Alt-F1 in DGV double-click?
I want to have a feature in my program where if I hold Alt-F1 down while double-clicking on a DataGridView cell, it goes & does something. I tried This:
Code:
Private Sub ProcessDataGridView_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ProcessDataGridView.CellDoubleClick
If Control.ModifierKeys = (Keys.Alt Or Keys.F1) Then
'do something here
End If
End Sub
If I use just Keys.Alt alone it works when I hold the Alt key & double-click, but I want ALt-F1. Can anyone help me out? Thanks...
Re: Read Alt-F1 in DGV double-click?
Did yopu try Keys.Alt + Keys.F1
Re: Read Alt-F1 in DGV double-click?
That's because F1 is not a modifier key.
Re: Read Alt-F1 in DGV double-click?
OK, so then it possible to read the Alt-F1 combo?
Re: Read Alt-F1 in DGV double-click?
Try this: Put the following code into the keydown event:
Code:
If e.Alt = True AndAlso e.KeyCode = Keys.F1 Then
'set a global bit = true
Else
'set bit = False
End If
Use the bit as a flag. Then when you click on the box have it check the bit. Now you know if the keycombo was pressed or not!
Good Luck, :wave:
D
Re: Read Alt-F1 in DGV double-click?
Thanks dminder, that works. Is this the only way it can be done?
Re: Read Alt-F1 in DGV double-click?
The key is that you have to detect the keypress prior to editing the cell. The keypress and the cell edit are 2 totally separate subs and do not know what the other is doing with out 3rd party assistance (enter the boolean).
I cannot think of any other way to do it, but if there are, I am sure others will post it!!
Good Luck again!
D