I have control (implemented C#, .Net 2.0) that inherits from combobox. It has filtering and other stuff. To keep UI right, when amount of items during filtering falls, drop down list changes its size to fit the number of items left (it is done by NativeMethods.SetWindowPos(...)).
Is there any way to check if drop down list is revealed up or down (literally) - not to check if it is open, it is open, but in which direction, upwards or downwards?
cheers, jbk
So i found an answer:
Here we have both handles to combobox:
And to dropdownlist of combobox:
Now, we can get rectangles from handles:
and
now we can check:
ComboBoxes open downwards or upwards depending on the space they have to open: if they have avaliable space below them they'll open downwards as usual, if not they'll open upwards.
So you simply have to check if they have space enough below them to know. Try this code:
The ComboBox has two events (
DropDown
andDropDownClosed
) that are fired when the dropdown part opens and closes, so you might want to attach handlers to them to monitor the state of the control.Alternatively, there's also a boolean property (
DroppedDown
) which should tell you the current state.