Jump to content
Sign in to follow this  
Archman

ComboBox - Option ? is selected - Sorted

Recommended Posts

Archman

I want to create a combo box with 4 options. I can make it return the text for each option but how do i make it return the number of the option selected?

$n1 = GUICtrlCreateCombo("", 10, 88, 300, 25)
GUICtrlSetData(-1, "Do this|Do that|Do something Else", "Do this")

So if "Do this" is selected i want it to return 1

"Do that" returns 2

"Do something else" returns 3

so that i can have something like

if GUICtrlRead($n1) = 1 Then 
      Code I want
EndIf

Doh!

if GUICtrlRead($n1) = "Do this" Then 
      Code I want
EndIf
Edited by Archman

Share this post


Link to post
Share on other sites
d3mon

I want to create a combo box with 4 options. I can make it return the text for each option but how do i make it return the number of the option selected?

$n1 = GUICtrlCreateCombo("", 10, 88, 300, 25)
GUICtrlSetData(-1, "Do this|Do that|Do something Else", "Do this")

So if "Do this" is selected i want it to return 1

"Do that" returns 2

"Do something else" returns 3

so that i can have something like

if GUICtrlRead($n1) = 1 Then 
      Code I want
EndIf

Doh!

if GUICtrlRead($n1) = "Do this" Then 
      Code I want
EndIf

Do you know read autoit help ? or you won't do any effort ?

GUICreate("",500,500)
$n1 = GUICtrlCreateCombo("", 10, 10, 300, 25)
GUICtrlSetData(-1, "Do this|Do that|Do something Else", "Do this")
GUISetState()

While 1
If GUICtrlRead($n1)="Do this" Then
;Your code
EndIf

If GUICtrlRead($n1)="Do that" Then
;Your code
EndIf

If GUICtrlRead($n1)="Do something Else" Then
;Your code
EndIf
WEnd

No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

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  

×