C# winforms, How can I make a Combobox open upwards / Is there one that does?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















In C#, a winforms application,



How can I make a Combobox that opens upwards / Is there one that opens upwards?



I see some questions like this but they refer to a WPF application rather than a winforms one. I'm asking about a winforms application.










share|improve this question























  • Not possible unless you write a control of your own.

    – Koby Douek
    Jun 4 '17 at 11:53






  • 4





    Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

    – Cody Gray
    Jun 4 '17 at 11:54











  • @KobyDouek perhaps one has been written that I can use?

    – barlop
    Jun 4 '17 at 11:54











  • It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

    – Cody Gray
    Jun 4 '17 at 11:57








  • 1





    Well, no, because there's plenty of room to display it on top of your oversized taskbar.

    – Cody Gray
    Jun 4 '17 at 11:59


















0















In C#, a winforms application,



How can I make a Combobox that opens upwards / Is there one that opens upwards?



I see some questions like this but they refer to a WPF application rather than a winforms one. I'm asking about a winforms application.










share|improve this question























  • Not possible unless you write a control of your own.

    – Koby Douek
    Jun 4 '17 at 11:53






  • 4





    Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

    – Cody Gray
    Jun 4 '17 at 11:54











  • @KobyDouek perhaps one has been written that I can use?

    – barlop
    Jun 4 '17 at 11:54











  • It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

    – Cody Gray
    Jun 4 '17 at 11:57








  • 1





    Well, no, because there's plenty of room to display it on top of your oversized taskbar.

    – Cody Gray
    Jun 4 '17 at 11:59














0












0








0








In C#, a winforms application,



How can I make a Combobox that opens upwards / Is there one that opens upwards?



I see some questions like this but they refer to a WPF application rather than a winforms one. I'm asking about a winforms application.










share|improve this question














In C#, a winforms application,



How can I make a Combobox that opens upwards / Is there one that opens upwards?



I see some questions like this but they refer to a WPF application rather than a winforms one. I'm asking about a winforms application.







c# winforms






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 4 '17 at 11:49









barlopbarlop

4,64354568




4,64354568













  • Not possible unless you write a control of your own.

    – Koby Douek
    Jun 4 '17 at 11:53






  • 4





    Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

    – Cody Gray
    Jun 4 '17 at 11:54











  • @KobyDouek perhaps one has been written that I can use?

    – barlop
    Jun 4 '17 at 11:54











  • It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

    – Cody Gray
    Jun 4 '17 at 11:57








  • 1





    Well, no, because there's plenty of room to display it on top of your oversized taskbar.

    – Cody Gray
    Jun 4 '17 at 11:59



















  • Not possible unless you write a control of your own.

    – Koby Douek
    Jun 4 '17 at 11:53






  • 4





    Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

    – Cody Gray
    Jun 4 '17 at 11:54











  • @KobyDouek perhaps one has been written that I can use?

    – barlop
    Jun 4 '17 at 11:54











  • It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

    – Cody Gray
    Jun 4 '17 at 11:57








  • 1





    Well, no, because there's plenty of room to display it on top of your oversized taskbar.

    – Cody Gray
    Jun 4 '17 at 11:59

















Not possible unless you write a control of your own.

– Koby Douek
Jun 4 '17 at 11:53





Not possible unless you write a control of your own.

– Koby Douek
Jun 4 '17 at 11:53




4




4





Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

– Cody Gray
Jun 4 '17 at 11:54





Drag the form to the bottom of your screen, then open the combo box. Like magic, it opens upwards!

– Cody Gray
Jun 4 '17 at 11:54













@KobyDouek perhaps one has been written that I can use?

– barlop
Jun 4 '17 at 11:54





@KobyDouek perhaps one has been written that I can use?

– barlop
Jun 4 '17 at 11:54













It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

– Cody Gray
Jun 4 '17 at 11:57







It's possible to achieve this effect by subclassing the control and manipulating its behavior using Windows API functions. (Start with code like this.) But the problem with this is that the OS uses slide effects, and there's no way to change the direction of these, so it'll appear to slide down and then the drop down list will appear above it. Ugly. Perhaps you can explain why you need to worry about this, instead of letting the window manager handle it automatically? Your design should not rely on the combo box dropping in any particular direction.

– Cody Gray
Jun 4 '17 at 11:57






1




1





Well, no, because there's plenty of room to display it on top of your oversized taskbar.

– Cody Gray
Jun 4 '17 at 11:59





Well, no, because there's plenty of room to display it on top of your oversized taskbar.

– Cody Gray
Jun 4 '17 at 11:59












2 Answers
2






active

oldest

votes


















1














This is not easy when working with WinForms, but I could give you my idea.



You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
So the idea is that creating a user control that contains 2 comboboxs:



Example of my user control



The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.



        private void cbb_main_Click(object sender, EventArgs e)
{
cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
cbb_main.DroppedDown = false;
cbb_2.DroppedDown = true;
}


Finally, add your custom control to the form and give it a try!
Result image here!



I hope this is what you're looking for.






share|improve this answer































    0














    If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.



    Downwards



    enter image description here





    Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.



    Upwards



    enter image description here





    Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.






    share|improve this answer


























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44353741%2fc-sharp-winforms-how-can-i-make-a-combobox-open-upwards-is-there-one-that-doe%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      This is not easy when working with WinForms, but I could give you my idea.



      You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
      So the idea is that creating a user control that contains 2 comboboxs:



      Example of my user control



      The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.



              private void cbb_main_Click(object sender, EventArgs e)
      {
      cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
      cbb_main.DroppedDown = false;
      cbb_2.DroppedDown = true;
      }


      Finally, add your custom control to the form and give it a try!
      Result image here!



      I hope this is what you're looking for.






      share|improve this answer




























        1














        This is not easy when working with WinForms, but I could give you my idea.



        You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
        So the idea is that creating a user control that contains 2 comboboxs:



        Example of my user control



        The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.



                private void cbb_main_Click(object sender, EventArgs e)
        {
        cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
        cbb_main.DroppedDown = false;
        cbb_2.DroppedDown = true;
        }


        Finally, add your custom control to the form and give it a try!
        Result image here!



        I hope this is what you're looking for.






        share|improve this answer


























          1












          1








          1







          This is not easy when working with WinForms, but I could give you my idea.



          You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
          So the idea is that creating a user control that contains 2 comboboxs:



          Example of my user control



          The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.



                  private void cbb_main_Click(object sender, EventArgs e)
          {
          cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
          cbb_main.DroppedDown = false;
          cbb_2.DroppedDown = true;
          }


          Finally, add your custom control to the form and give it a try!
          Result image here!



          I hope this is what you're looking for.






          share|improve this answer













          This is not easy when working with WinForms, but I could give you my idea.



          You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
          So the idea is that creating a user control that contains 2 comboboxs:



          Example of my user control



          The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.



                  private void cbb_main_Click(object sender, EventArgs e)
          {
          cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
          cbb_main.DroppedDown = false;
          cbb_2.DroppedDown = true;
          }


          Finally, add your custom control to the form and give it a try!
          Result image here!



          I hope this is what you're looking for.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 4 '17 at 12:24









          Rogger TânRogger Tân

          7736




          7736

























              0














              If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.



              Downwards



              enter image description here





              Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.



              Upwards



              enter image description here





              Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.






              share|improve this answer






























                0














                If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.



                Downwards



                enter image description here





                Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.



                Upwards



                enter image description here





                Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.






                share|improve this answer




























                  0












                  0








                  0







                  If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.



                  Downwards



                  enter image description here





                  Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.



                  Upwards



                  enter image description here





                  Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.






                  share|improve this answer















                  If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.



                  Downwards



                  enter image description here





                  Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.



                  Upwards



                  enter image description here





                  Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 23 '18 at 14:18

























                  answered Nov 23 '18 at 14:13









                  barlopbarlop

                  4,64354568




                  4,64354568






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44353741%2fc-sharp-winforms-how-can-i-make-a-combobox-open-upwards-is-there-one-that-doe%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Xamarin.form Move up view when keyboard appear

                      Post-Redirect-Get with Spring WebFlux and Thymeleaf

                      Anylogic : not able to use stopDelay()