ctrl-click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    ctrl-click

    Hi,

    I would like to know wether the Ctrl-key is pressed down
    when i click a button on my win form.

    how can i do this?

    tia,

    Tom
  • One Handed Man [ OHM# ]

    #2
    Re: ctrl-click

    First of all set your forms KeyPreview property to True, then trap the
    KeyDown or KeyUp events and find out.


    Regards - OHM



    Tom wrote:[color=blue]
    > Hi,
    >
    > I would like to know wether the Ctrl-key is pressed down
    > when i click a button on my win form.
    >
    > how can i do this?
    >
    > tia,
    >
    > Tom[/color]

    --
    Best Regards - OHM

    O_H_M{at}BTInte rnet{dot}com


    Comment

    • lostdreamz

      #3
      Re: ctrl-click

      OHM/Tom,

      There is an easy way to find out if Ctrl is held down when you press a
      button.

      In the Click event of the button, you can see if the Ctrl key is
      currently pressed down with the following code .

      If btnYourButton.M odifierKeys = Keys.Control Then
      MsgBox("The control key is currently pressed down.")
      End If


      lostdreamz

      On Tue, 13 Jan 2004 15:34:10 -0000, "One Handed Man [ OHM# ]"
      <O_H_M{at}BTInt ernet{dot}com> wrote:
      [color=blue]
      >First of all set your forms KeyPreview property to True, then trap the
      >KeyDown or KeyUp events and find out.
      >
      >
      >Regards - OHM
      >
      >
      >
      >Tom wrote:[color=green]
      >> Hi,
      >>
      >> I would like to know wether the Ctrl-key is pressed down
      >> when i click a button on my win form.
      >>
      >> how can i do this?
      >>
      >> tia,
      >>
      >> Tom[/color][/color]

      Comment

      • One Handed Man [ OHM# ]

        #4
        Re: ctrl-click

        I misread it, I thought he wanted it trapped anywhere on the form.

        lostdreamz wrote:[color=blue]
        > OHM/Tom,
        >
        > There is an easy way to find out if Ctrl is held down when you press a
        > button.
        >
        > In the Click event of the button, you can see if the Ctrl key is
        > currently pressed down with the following code .
        >
        > If btnYourButton.M odifierKeys = Keys.Control Then
        > MsgBox("The control key is currently pressed down.")
        > End If
        >
        >
        > lostdreamz
        >
        > On Tue, 13 Jan 2004 15:34:10 -0000, "One Handed Man [ OHM# ]"
        > <O_H_M{at}BTInt ernet{dot}com> wrote:
        >[color=green]
        >> First of all set your forms KeyPreview property to True, then trap
        >> the KeyDown or KeyUp events and find out.
        >>
        >>
        >> Regards - OHM
        >>
        >>
        >>
        >> Tom wrote:[color=darkred]
        >>> Hi,
        >>>
        >>> I would like to know wether the Ctrl-key is pressed down
        >>> when i click a button on my win form.
        >>>
        >>> how can i do this?
        >>>
        >>> tia,
        >>>
        >>> Tom[/color][/color][/color]

        --
        Best Regards - OHM

        O_H_M{at}BTInte rnet{dot}com


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: ctrl-click

          * lostdreamz <ybfgqernzm850@ ubgznvy.pbz> scripsit:[color=blue]
          > There is an easy way to find out if Ctrl is held down when you press a
          > button.
          >
          > In the Click event of the button, you can see if the Ctrl key is
          > currently pressed down with the following code .
          >
          > If btnYourButton.M odifierKeys = Keys.Control Then[/color]

          Better:

          \\\
          If (Control.Modifi erKeys And Keys.Control) <> 0 Then
          ...
          End If
          ///

          --
          Herfried K. Wagner [MVP]
          <http://www.mvps.org/dotnet>

          Comment

          Working...