Up Down Arrows as TAB Key

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

    Up Down Arrows as TAB Key

    Hello:

    I'm tring to make the down arrow act as a tab key and the up arrow act as
    like (-TAB.).

    I have this for the down arrow but nothing happens.

    Protected Overrides Function ProcessDialogKe y(ByVal keyData As Keys) As
    Boolean
    MyBase.ProcessD ialogKey(keyDat a)
    If keyData = System.Windows. Forms.Keys.Down Then
    keyData = System.Windows. Forms.Keys.Tab
    End If
    End Function


    TIA

    Bob


  • Some Guy

    #2
    Re: Up Down Arrows as TAB Key

    Put the call to the MyBase.ProcessD ialogKey(keyDat a) AFTER the if
    statement.

    Protected Overrides Function ProcessDialogKe y(ByVal keyData As
    System.Windows. Forms.Keys) As Boolean
    If keyData = Keys.Down Then
    keyData = Keys.Tab
    End If
    MyBase.ProcessD ialogKey(keyDat a)
    End Function


    "Bob" <nojunk@nospamm ers.com> wrote in message
    news:C2hRe.2681 6$FL1.13685@trn ddc09...[color=blue]
    > Hello:
    >
    > I'm tring to make the down arrow act as a tab key and the up arrow act as
    > like (-TAB.).
    >
    > I have this for the down arrow but nothing happens.
    >
    > Protected Overrides Function ProcessDialogKe y(ByVal keyData As Keys) As
    > Boolean
    > MyBase.ProcessD ialogKey(keyDat a)
    > If keyData = System.Windows. Forms.Keys.Down Then
    > keyData = System.Windows. Forms.Keys.Tab
    > End If
    > End Function
    >
    >
    > TIA
    >
    > Bob
    >[/color]


    Comment

    • Bob

      #3
      Re: Up Down Arrows as TAB Key

      Some Guy:

      Strange how my original post didn't show up where I intended. Thanks for the
      response despite my screw up.

      Your sugextion looks like it should work based on other articles. I'm
      thinking I'm missing one little bit of this. Maybe I'm putting it in the
      wrong place in my code.

      I tried calling it from a controle like this

      Dim MyKey As System.Windows. Forms.Keys
      MyBase.ProcessD ialogKey(MyKey)

      Yet nothing happens. I would like it to work through out the whole form. Do
      I need to raise the event somewhere? Also, will it slow things down or would
      I be better to try to convince the client to use traditional methods to
      navigate the controles. Please keep in mind I have 327 controles.

      Thanks Again

      TIA

      Bob


      Comment

      • Some Guy

        #4
        Re: Up Down Arrows as TAB Key

        This code sets MyKey to none. So nothing happens.

        Dim MyKey As System.Windows. Forms.Keys
        MyBase.ProcessD ialogKey(MyKey)

        Try: Dim MyKey As System.Windows. Forms.Keys=Keys .Tab

        "Bob" <nojunk@nospamm ers.com> wrote in message
        news:ZeCRe.7650 $__1.4593@trndd c07...[color=blue]
        > Some Guy:
        >
        > Strange how my original post didn't show up where I intended. Thanks for
        > the response despite my screw up.
        >
        > Your sugextion looks like it should work based on other articles. I'm
        > thinking I'm missing one little bit of this. Maybe I'm putting it in the
        > wrong place in my code.
        >
        > I tried calling it from a controle like this
        >
        > Dim MyKey As System.Windows. Forms.Keys
        > MyBase.ProcessD ialogKey(MyKey)
        >
        > Yet nothing happens. I would like it to work through out the whole form.
        > Do I need to raise the event somewhere? Also, will it slow things down or
        > would I be better to try to convince the client to use traditional methods
        > to navigate the controles. Please keep in mind I have 327 controles.
        >
        > Thanks Again
        >
        > TIA
        >
        > Bob
        >[/color]


        Comment

        • hayworth@hotmail.com

          #5
          Re: Up Down Arrows as TAB Key

          keyData is passed in by value, so how can you change it? I don't
          believe you can change the value of an argument unless it has been
          passed in by reference, so I don't believe your function will actually
          change the value of keyData. In fact, I'm surprised you don't get an
          exception there.

          I think you have to use the focus method to change focus, something
          like
          If keyData = System.Windows. Forms.Keys.Down Then
          cmdNextButton.F ocus()
          End If
          And I think you'd have to keep track of the order you want the tabs to
          go in, or else search all the control properties yourself to find out
          which one should get focus next and then manually set focus to that
          particular control. In VB6 I've used a function (API function I think)
          called SendKeys. Perhaps you can use that to send a tab to your
          application whenever it sees a down arrow. I've not used it yet in
          vb.net. Perhaps something like (not sure of the SendKey args):
          If keyData = System.Windows. Forms.Keys.Down Then
          SendKeys(applic ation.hInstance ,
          System.Windows. Forms.Keys.Tab)
          End If

          Good luck.
          Mark H.

          Comment

          • Bob

            #6
            Re: Up Down Arrows as TAB Key

            Some Guy & Mark:

            Thanks to both of you for the responses. Some Guy's response actually made
            it so all the keys acted as a TAB key. However, this gave me some leads to
            work with and helped me figure it out.

            Mark.

            I certainly see what you mean and when you look below at the code that is
            working, you'll fall of your chair. I still have not fully tested it but so
            far it works ok with one small yet probably resolvable issue. I've yet to
            have any errors at all.

            Protected Overrides Function ProcessDialogKe y(ByVal keyData As
            System.Windows. Forms.Keys) As Boolean
            'MyBase.Process DialogKey(keyDa ta) <<--Note that this line is
            comented out.
            End Function

            'If I remove the above function entirely, the down arrow does nothing. Even
            when I press it in other Private Subs for 'KeyDown events in other controles
            and the TAB key doesn't work at all. Strange don't you think?

            Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As
            System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown
            Dim MyKey As System.Windows. Forms.Keys
            If e.KeyCode = Keys.Down Then
            MyKey = Keys.Tab
            ElseIf e.KeyCode = Keys.Tab Then
            MyKey = Keys.Tab
            End If
            MyBase.ProcessD ialogKey(MyKey)
            End Sub

            The one small issue to resolve as of now is the following

            I have an inherited user controle I made. It's a TextBox that I set to
            MultiLine = True and ScrollBars = Verticle in my application(Not when I
            built the controle). It's designed to move to the upper left portion of the
            form and resize to (636, 326) when the F1 key is pressed and return to it's
            original size and position when ESC is pressed. This also continues to
            function as it should.

            The down arrow acts as a TAB key intill it encounters my controle. When the
            cursor reaches my controle, the down arrow key does nothing untill I press
            the TAB key or click the next controle. Then the down arrow again functions
            as the TAB key. However, the TAB key continues to function normally through
            out all the controles on the form.

            YEAH, I'm scratching my head too.

            Bob


            Comment

            • Bob

              #7
              Re: Up Down Arrows as TAB Key

              Mark:
              [color=blue]
              >I think you have to use the focus method to change focus, something like[/color]
              [color=blue]
              > If keyData = System.Windows. Forms.Keys.Down Then
              > cmdNextButton.F ocus()
              > End If[/color]



              I forgot to mention,

              That would take a lot of code as I have more than 327 controles on my form
              that TabStop = True. I must intercept the Down Arrow key press in the forms
              KeyDown event.
              [color=blue]
              > If keyData = System.Windows. Forms.Keys.Down Then
              > SendKeys(applic ation.hInstance , System.Windows. Forms.Keys.Tab)
              > End If[/color]

              Now thats interesting. I may able to refine my code with what you gave me.
              I'll be sure and post my results.

              Thank you

              Bob


              Comment

              • Some Guy

                #8
                Re: Up Down Arrows as TAB Key

                What's the problem?

                Protected Overrides Function ProcessDialogKe y(ByVal keyData As
                System.Windows. Forms.Keys) As Boolean
                If keyData = Keys.Up Then
                keyData = Keys.Tab
                MyBase.ProcessD ialogKey(keyDat a)
                End If
                End Function



                "Bob" <nojunk@nospamm ers.com> wrote in message
                news:41_Re.229$ AB4.42@trnddc03 ...[color=blue]
                > Mark:
                >[color=green]
                >>I think you have to use the focus method to change focus, something like[/color]
                >[color=green]
                >> If keyData = System.Windows. Forms.Keys.Down Then
                >> cmdNextButton.F ocus()
                >> End If[/color]
                >
                >
                >
                > I forgot to mention,
                >
                > That would take a lot of code as I have more than 327 controles on my form
                > that TabStop = True. I must intercept the Down Arrow key press in the
                > forms KeyDown event.
                >[color=green]
                >> If keyData = System.Windows. Forms.Keys.Down Then
                >> SendKeys(applic ation.hInstance , System.Windows. Forms.Keys.Tab)
                >> End If[/color]
                >
                > Now thats interesting. I may able to refine my code with what you gave me.
                > I'll be sure and post my results.
                >
                > Thank you
                >
                > Bob
                >[/color]


                Comment

                • Bob

                  #9
                  Re: Up Down Arrows as TAB Key

                  Some Guy:

                  There is no problem. You've been a great help. Someone else responded also
                  and maybe he didn't see your post so maybe he thought is wasn't resolved. He
                  didn't seem to think it would work at all but actually it works great. It
                  was just hanging on one of my inherited user controles but I fixed that too
                  with a little modification to my controle.

                  Thanks for helping

                  Bob


                  Comment

                  • Bob

                    #10
                    Re: Up Down Arrows as TAB Key

                    Some guy:

                    I'm sorry. My response was to Marks response. HEHEHE. Everything is fine.

                    Thanks again

                    Bob


                    Comment

                    • hayworth@hotmail.com

                      #11
                      Re: Up Down Arrows as TAB Key

                      Bob:
                      Your new code should work now because you are no longer changing the
                      key that was passed in by value. You're making a new vairable MyKey
                      and then (recursively sort of) calling the function again but with
                      MyKey instead of the original key. I think this should work.

                      Not exactly sure about your other problem but maybe since it's a text
                      field it's different. Maybe the text field has focus and is expecting
                      you to type something into it, and it thinks the arrow key is just like
                      any other key you might want to type, like regular letters, etc. You
                      might have to make this a special case and put some code into the event
                      (if it has one) for that control that gets fired off when the value
                      changes.
                      Mark H.

                      Comment

                      Working...