Results 1 to 7 of 7

Thread: Read Alt-F1 in DGV double-click?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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...

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Read Alt-F1 in DGV double-click?

    Did yopu try Keys.Alt + Keys.F1
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Read Alt-F1 in DGV double-click?

    That's because F1 is not a modifier key.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Read Alt-F1 in DGV double-click?

    OK, so then it possible to read the Alt-F1 combo?

  5. #5
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    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,

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Read Alt-F1 in DGV double-click?

    Thanks dminder, that works. Is this the only way it can be done?

  7. #7
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    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
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width