I use a subclassed Combobox which auto drops down using the following code:
METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
IF lGotFocus // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF
Problem is when I assign a value to the combobox manually it also drops down where it shouldn't. I thought to counteract that as follows:
SELF:oDCMyComboBox:VALUE:="Some value present in the elements of the combobox"
SendMessage(SELF:oDCMyComboBox:Handle(), CB_SHOWDROPDOWN,0, 0)
but it does not collapse and stays dropped down.
How can I achieve that?
Dick
Collapse drop down in combobox from the program? (SOLVED)
Collapse drop down in combobox from the program?
Hi Dick,
What about:
EXPORT lDrop := TRUE as LOGIC
METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
IF lGotFocus .and. SELF:lDrop // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF
SELF:lDrop := TRUE
METHOD Set_Value( uNewValue as usual)
self:value := uNewValue
self:lDrop := FALSE
RETURN NIL
Then assign as per below:
SELF:oDCMyComboBox:Set_Value( "Some value present in the elements of the combobox")
Haven't tested this, but might help.
Regards,
Tim
What about:
EXPORT lDrop := TRUE as LOGIC
METHOD FocusChange( oEvent ) CLASS Ic2ComboBox
IF lGotFocus .and. SELF:lDrop // Drop down automatically each time control receives focus
PostMessage( SELF:Handle(), CB_SHOWDROPDOWN, 1, 0L )
ENDIF
SELF:lDrop := TRUE
METHOD Set_Value( uNewValue as usual)
self:value := uNewValue
self:lDrop := FALSE
RETURN NIL
Then assign as per below:
SELF:oDCMyComboBox:Set_Value( "Some value present in the elements of the combobox")
Haven't tested this, but might help.
Regards,
Tim
Collapse drop down in combobox from the program?
Might be better to swap:Timothy Shea wrote:Code: Select all
METHOD Set_Value( uNewValue as usual) self:value := uNewValue self:lDrop := FALSE RETURN NIL
self:lDrop := FALSE
self:value := uNewValue
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Collapse drop down in combobox from the program?
Hello Thomoty, Karl,
Thanks for the reply. This is one of those situations where it's hard to understand what the computer is doing. I tried something like this already and refined it with your remarks. What happened?
// Set the lDropDown variable here
SELF:oDCMyComboBox:VALUE:="Some value"
- Despite the above settings, _Debout shows lDropDown is false in FocusChange!
- The FocusChange does NOT seem to be called directly after assigning a value. I put a few statements with waiting time in it to see what happens
- Then some totally unrelated code is executed
- AFTER THAT the FocusChange is executed, with lDropDown false, so still dropping down the combobox.
Solved
I did solve it however:
PostMessage( SELF:oDCMyComboBox:Handle(), CB_SHOWDROPDOWN, 0, 0L )
Contrary to SendMessage this statement actively lets the combobox collapse. It now drops down and directly collapses at the right time, where the statement is exectuted.
Dick
Thanks for the reply. This is one of those situations where it's hard to understand what the computer is doing. I tried something like this already and refined it with your remarks. What happened?
// Set the lDropDown variable here
SELF:oDCMyComboBox:VALUE:="Some value"
- Despite the above settings, _Debout shows lDropDown is false in FocusChange!
- The FocusChange does NOT seem to be called directly after assigning a value. I put a few statements with waiting time in it to see what happens
- Then some totally unrelated code is executed
- AFTER THAT the FocusChange is executed, with lDropDown false, so still dropping down the combobox.
Solved
I did solve it however:
PostMessage( SELF:oDCMyComboBox:Handle(), CB_SHOWDROPDOWN, 0, 0L )
Contrary to SendMessage this statement actively lets the combobox collapse. It now drops down and directly collapses at the right time, where the statement is exectuted.
Dick