Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to develop an user control which is very similar to combo box control. It is also having a drop down portion. When click the control drop down portion pops up. Clicking any where on the parent form dropped down portion gets hidden. This works for me as long as I click on the Parent form. Clicking on a container control like Group box it does not work. So, any body can suggest what should be the technique or concept to be used to hide the drop down portion by clicking any where on the screen.

What I have tried:

I have added a handler for parent form click.
AddHandler Me.ParentForm.Click, AddressOf PForm_Click
sub PForm_Click()
Hide drop down
end sub
Posted
Updated 18-Jan-21 5:48am

1 solution

Most drop downs are created by showing a new window (or control in .NET) - so you hide it by either calling Hide on it, or Closing it and removing it from the Controls collection of it's "parent" control.

And by the way - instead of Form/Click, you might find that handling the dropdown's LostFocus event (Control.LostFocus Event (System.Windows.Forms) | Microsoft Docs[^]) would be a better idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900