Keltset Posted August 22, 2013 Posted August 22, 2013 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
abberration Posted August 23, 2013 Posted August 23, 2013 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? Easy MP3 | Software Installer | Password Manager
Solution LarsJ Posted August 23, 2013 Solution Posted August 23, 2013 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 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Keltset Posted August 24, 2013 Author Posted August 24, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now