Search code examples
c#winformscontrolspropertygrid

Programmatically show PropertyGrid active control's editing control


I'll try to explain the effect I want to achieve. Basically, when user select a particular property (whose accepted values will be presented in a drop down) I'd like the dropdown to show IMMEDIATELY, without the need to click the drop down button. So far i'v been trying some weird/ugly solutions with no success (like trying to raise a MouseClick on the dropdown button...) so I hope there is a simpler/not-so-ugly one.


Solution

  • Add the following code to an event handler for the SelectedGridItemChanged:

    if(e.NewSelected.Label == "Your Property Name")
    {
      SendKeys.Send("%{DOWN}");
    }
    

    This sends an ALT+DOWN key press combination which will show the drop-down list of values for the property.