pull down combobpx

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivan V via DotNetMonster.com

    #1

    pull down combobpx

    Hi All:

    How can I activate the spacebar to pull down the combobox?

    For instance, once the tab stopped at the combobox, suppose i can use dnarrow
    or F4 to pull down the combobox to make selection, but instead of these 2
    keys, I want to use spacebar, can I do that?

    Best rgds,
    Ivan Vong


    --
    Message posted via http://www.dotnetmonster.com
  • Herfried K. Wagner [MVP]

    #2
    Re: pull down combobpx

    "Ivan V via DotNetMonster.c om" <forum@DotNetMo nster.com> schrieb:[color=blue]
    > How can I activate the spacebar to pull down the combobox?[/color]

    Set the control's 'DroppedDown' property to 'True'.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Patrick Steele [MVP]

      #3
      Re: pull down combobpx

      In article <52E24AD468808@ DotNetMonster.c om>, forum@DotNetMon ster.com
      says...[color=blue]
      > Hi All:
      >
      > How can I activate the spacebar to pull down the combobox?
      >
      > For instance, once the tab stopped at the combobox, suppose i can use dnarrow
      > or F4 to pull down the combobox to make selection, but instead of these 2
      > keys, I want to use spacebar, can I do that?[/color]

      I would subclass the regular combobox and handle the OnKeyDown method:

      Public Class MyComboBox
      Inherits ComboBox

      ' abstract method. just call base class method
      Protected Overrides Sub RefreshItem(ByV al index As Integer)
      MyBase.RefreshI tem(index)
      End Sub

      ' abstract method. just call base class method
      Protected Overrides Sub SetItemsCore(By Val items As
      System.Collecti ons.IList)
      MyBase.SetItems Core(items)
      End Sub

      Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
      If e.KeyCode = Keys.Space Then
      Me.DroppedDown = Not Me.DroppedDown
      e.Handled = True
      End If
      End Sub
      End Class

      All this does is that when the space key is pressed, it will toggle the
      dropdown to either on or off.

      --
      Patrick Steele
      Microsoft .NET MVP

      Comment

      • Ivan V via DotNetMonster.com

        #4
        Re: pull down combobpx

        i did try, but it's not working!!!


        --
        Message posted via http://www.dotnetmonster.com

        Comment

        • Ivan V via DotNetMonster.com

          #5
          Re: pull down combobpx

          both method is not working!


          --
          Message posted via http://www.dotnetmonster.com

          Comment

          • Patrick Steele [MVP]

            #6
            Re: pull down combobpx

            In article <52E289E2A588C@ DotNetMonster.c om>, forum@DotNetMon ster.com
            says...[color=blue]
            > both method is not working![/color]

            The code was copied directly out of a working project. Could you give
            more detail as to what "is not working" means? Are you getting errors?
            Can you provide some sample code?

            This is a winform app, correct?

            --
            Patrick Steele
            Microsoft .NET MVP

            Comment

            • Ivan V via DotNetMonster.com

              #7
              Re: pull down combobpx

              Yes, it's a vb.net application. I just simply add the code that you provided
              to me. My comob box named Type, and nothing had changed when the code has
              been added!!!


              --
              Message posted via http://www.dotnetmonster.com

              Comment

              • Patrick Steele [MVP]

                #8
                Re: pull down combobpx

                In article <52E2BBFD60F14@ DotNetMonster.c om>, forum@DotNetMon ster.com
                says...[color=blue]
                > Yes, it's a vb.net application. I just simply add the code that you provided
                > to me. My comob box named Type, and nothing had changed when the code has
                > been added!!![/color]

                You also need to change the VS.NET generated code. Right now it's
                creating a standard System.Windows. Forms.ComboBox. You'd need to change
                that to "MyComboBox " (if you use the sample code I provided).

                --
                Patrick Steele
                Microsoft .NET MVP

                Comment

                • Ivan V via DotNetMonster.com

                  #9
                  Re: pull down combobpx

                  Thanks Patrick, it works great for me now. How about to activate the up arrow
                  and down arrow in our keyboard in a window from as the function of tab key?


                  --
                  Message posted via http://www.dotnetmonster.com

                  Comment

                  • Patrick Steele [MVP]

                    #10
                    Re: pull down combobpx

                    In article <52E2DCA2AA9DC@ DotNetMonster.c om>, forum@DotNetMon ster.com
                    says...[color=blue]
                    > Thanks Patrick, it works great for me now. How about to activate the up arrow
                    > and down arrow in our keyboard in a window from as the function of tab key?[/color]

                    I'm not sure what you're asking. Do you want the up/down arrow keys to
                    allow you to move focus around the form like TAB and SHIFT+TAB? Or do
                    you want the TAB and SHIFT+TAB keys to act like the up/down arrow keys?

                    --
                    Patrick Steele
                    Microsoft .NET MVP

                    Comment

                    • Ivan V via DotNetMonster.com

                      #11
                      Re: pull down combobpx

                      It's the former one which the up/down arrow keys allow me to move focus
                      around like the TAB and SHIFT + TAB.
                      Thanks for your attention!


                      --
                      Message posted via http://www.dotnetmonster.com

                      Comment

                      Working...