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. Preventing the dropdown from being opened when drop down button pressed in combobox?

Preventing the dropdown from being opened when drop down button pressed in combobox?

Scheduled Pinned Locked Moved C#
question
2 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.
  • R Offline
    R Offline
    Ron bharath
    wrote on last edited by
    #1

    Hello All, I have an issues, i want to cancel the dropdown from being opened after validating the dropdown button clicked. i tried with setting droppeddown property to true as suggested by one of the member from this forum in earlier post. But that is also not avoiding the dropdown from being opened. I also tried to override the wndProc method and canceling the event it self but that is also not working . Please suggest me what i need to do so that i can avoid the dropdown after custom validation. Thanks in Advance. Ron

    H 1 Reply Last reply
    0
    • R Ron bharath

      Hello All, I have an issues, i want to cancel the dropdown from being opened after validating the dropdown button clicked. i tried with setting droppeddown property to true as suggested by one of the member from this forum in earlier post. But that is also not avoiding the dropdown from being opened. I also tried to override the wndProc method and canceling the event it self but that is also not working . Please suggest me what i need to do so that i can avoid the dropdown after custom validation. Thanks in Advance. Ron

      H Offline
      H Offline
      Hessam Jalali
      wrote on last edited by
      #2

      Hello, I think this can be done by intercepting WM_COMMAND message in "WndProc" method. this may help

      public class SuperComboBox:ComboBox
      {
      public class DropDownValidate:EventArgs
      {
      public bool AllowDropDown{get;set;}

              public DropDownValidate()
              {
                  this.AllowDropDown = true;
              }
          }
      
          private const int WM\_COMMAND = 0x0111;
      
          public event EventHandler<DropDownValidate> ValidateOnDropDown;
      
          private bool \_haltDrop;
      
          protected virtual void OnValidateDropDown(DropDownValidate e)
          {
              if (this.ValidateOnDropDown != null)
                  this.ValidateOnDropDown(this, e);
          }
      
          protected override void WndProc(ref Message m)
          {
              if (m.Msg == WM\_COMMAND)
              {
                  var validationArg = new DropDownValidate();
                  this.OnValidateDropDown(validationArg);
                  \_haltDrop = !validationArg.AllowDropDown;
                  if (\_haltDrop) return;
              }
              base.WndProc(ref m);
          }
      }
      

      Good luck

      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