Jump to content

Set Combo selection


blindwig
 Share

Recommended Posts

I can't seem to figure out how to set a combobox selection. Say I create a combo referenced as $combo using GUICtrlCreateCombo.

;this works:
GUICtrlSetData($combo,$default,$default)
;but if $default isn't already in the list, it gets added

;So I tried this:
GUICtrlSetData($combo,GUICtrlRead($combo),$default)
;but it doesn't work either

;I wish this would work:
GUICtrlSetData($combo,'',$default)
;but it clears the list

;this doesn't seem to work:
ControlCommand('','',$combo,'SetCurrentSelection',$default)
;it just returns 1 no matter what

I need to set the default to a string, but I don't know if that string is already in there or not. I don't want to add it if it isn't. I can't figure out how to check the list. I try using ControlCommand, but it returns 1 regardless.

Link to comment
Share on other sites

Big correction...

Have a look at some of the UDF's in the latest beta.

Specifically _GUICtrlComboBoxSelectString (currently mispelled as _GUICtrlCombBoxSelectString).

Or if you don't want the UDF, here's the guts of the function done up for your purposes:

Dim Const $CB_SELECTSTRING = 0x14D
GUICtrlSendMsg($combo, $CB_SELECTSTRING, 1, $default)

I think that should do it.

Edited by Saunders
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...