Jump to content
Sign in to follow this  
Keltset

Combo Box selection text?

Recommended Posts

Keltset

Hello,

I have a combo box that I want to create the selectable options in a dynamic way. So I feel terrible for asking but I'm just not finding it in the search or in the help. It looks like you can only retrieve the number of the item selection, is there a way to grab the actual text content of the selection instead?

IE my string is made up like this:

$string =  '"a|b|c|d|e|f|g", "c"'

GUICtrlSetData($GUI_Combo_Action, $string)

Because $string would actually be created dynamically I don't know how to associate an action when all I need to know is the actual text value of the selection. In this case, how do I retrieve "c" as it's value instead of  "2"

I'm so sorry if this has been asked, which I'm sure it has- I'm just tired and not finding what I need for this project. Any help is greatly appreciated.

-K


-K

Share this post


Link to post
Share on other sites
abberration

On GuiCtrlSetData, you can set the default value with the third criteria - ex: GuiCtrlSetData(control, data, default).

In the case you listed above, it would be something like:

$string =  "a|b|c|d|e|f|g"
$default = "c"
GuiCtrlSetData($GUI_Combo_Action, $string, $default)

 

Is that close to that you wanted?


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites
LarsJ

You can get the text with GUICtrlRead:

 

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg, $idCombo

    GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

    $idCombo = GUICtrlCreateCombo("item1", 10, 10) ; create first item
    GUICtrlSetData($idCombo, "item2|item3", "item3") ; add other item snd set a new default
    GUICtrlSetData($idCombo, "a|b|c|d|e|f|g", "c") ; add other item snd set a new default

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $idCombo Then _
            MsgBox( 0, "Combo text", GUICtrlRead( $idCombo ) )

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites
Keltset

Thank you kindly for the replies. I had posted with the default being 'c' however if the user were to change it I would still need to be able to grab the text dynamically.

I was trying to use GUICtrlComboBox_GetCurSel($mycombo) Thank you for the pointer on GuiCtrlRead, I did no realize I could use that on a combo box- I'm not sure why I had not just tried it before. I thank you both very much for the assistance: It is greatly appreciated!!!

-K


-K

Share this post


Link to post
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
Sign in to follow this  

×