Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# equivalent for ShowDropDown?

C# equivalent for ShowDropDown?

Scheduled Pinned Locked Moved C#
csharpc++question
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kozu
    wrote on last edited by
    #1

    Hi, I'm trying to prevent a combo box from displaying the dropdown when the user clicks on it. MFC's ShowDropDown(false) was doing this. Is there a way to accomplish the same result in C#? thanx

    M 1 Reply Last reply
    0
    • K kozu

      Hi, I'm trying to prevent a combo box from displaying the dropdown when the user clicks on it. MFC's ShowDropDown(false) was doing this. Is there a way to accomplish the same result in C#? thanx

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, You just have to set the Boolean property "DroppedDown" to "true". All the best, Martin

      K 1 Reply Last reply
      0
      • M Martin 0

        Hello, You just have to set the Boolean property "DroppedDown" to "true". All the best, Martin

        K Offline
        K Offline
        kozu
        wrote on last edited by
        #3

        Martin, I tried that, but the dropdown flickers. It comes up and it dissapears right away. Is there a way to prevent it from appearing? thanx

        M 1 Reply Last reply
        0
        • K kozu

          Martin, I tried that, but the dropdown flickers. It comes up and it dissapears right away. Is there a way to prevent it from appearing? thanx

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, On which eventhandler are you linked to when you set the property?

          K 1 Reply Last reply
          0
          • M Martin 0

            Hello, On which eventhandler are you linked to when you set the property?

            K Offline
            K Offline
            kozu
            wrote on last edited by
            #5

            I'm doing it on DropDown event: this.comboBox1.DropDown += new System.EventHandler(this.comboBox1_DropDown_1); ........... private void comboBox1_DropDown_1(object sender, System.EventArgs e) { this.comboBox1.DroppedDown = true; } It's pretty weird. The first click won't show it, but the second click will.

            M 1 Reply Last reply
            0
            • K kozu

              I'm doing it on DropDown event: this.comboBox1.DropDown += new System.EventHandler(this.comboBox1_DropDown_1); ........... private void comboBox1_DropDown_1(object sender, System.EventArgs e) { this.comboBox1.DroppedDown = true; } It's pretty weird. The first click won't show it, but the second click will.

              M Offline
              M Offline
              Martin 0
              wrote on last edited by
              #6

              Hmmm, I don't understand why you are doing that! You said that you whant it to show when the user clicks the control. So I would rather use the click or mousedown event of the combobox. Hope it helps! All the best, Martin

              K 1 Reply Last reply
              0
              • M Martin 0

                Hmmm, I don't understand why you are doing that! You said that you whant it to show when the user clicks the control. So I would rather use the click or mousedown event of the combobox. Hope it helps! All the best, Martin

                K Offline
                K Offline
                kozu
                wrote on last edited by
                #7

                No Martin, I want to prevent the combo from showing the dropdown (the reason is that i'm doing something else instead of showing the list). I think I'll just fake it with an edit & a button.

                M 1 Reply Last reply
                0
                • K kozu

                  No Martin, I want to prevent the combo from showing the dropdown (the reason is that i'm doing something else instead of showing the list). I think I'll just fake it with an edit & a button.

                  M Offline
                  M Offline
                  Martin 0
                  wrote on last edited by
                  #8

                  Ohh, Than I missunderstod what you actually wanted to do. I made a little test project for you, which is doing: The dropdown box should be shown if the left mouse button is clicked, but not if the right mouse button is clicked. I'm using the mousedown event for that.

                  	private System.Windows.Forms.ContextMenu emptymenu = new ContextMenu();
                  	private System.Windows.Forms.ContextMenu oldmenu;
                  	private void button1\_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
                  	{
                  		if(e.Button == MouseButtons.Right)
                  		{
                  			if(button1.ContextMenu!=emptymenu)
                  				oldmenu = button1.ContextMenu;	//this will save the original menu.
                  
                  			button1.ContextMenu = emptymenu; //this setts a empty menu to the property, which has the effect that no menu is shown.
                  		}
                  		else if(e.Button == MouseButtons.Left)
                  		{
                  			if(oldmenu!=null)	//the right mouse button was already pressed
                  			{
                  				button1.ContextMenu = oldmenu;
                  			}
                  			button1.ContextMenu.Show(button1, new Point(e.X,e.Y));
                  		}
                  	}
                  

                  Hope it helps! All the best, Martin

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups