Jump to content
Sign in to follow this  
Xtupid

Trouble with combo box

Recommended Posts

Xtupid

hi everybody! I having a trouble with AutoIT combo box

I have create a combo box:

GUICtrlSetData(-1, "line1|line2|line 3|line 4|line 5|line 6")

And now, when user chose a line, I want display the line's number. Plz help me

At last, English isn't my language, so that please don't angry with me :)

ps:I learn autoit recently by the help file...


Please don't angry if I wrote something wrong because my English vocabulary is very little....

Share this post


Link to post
Share on other sites
Triblade

If you use the latest AutoIt version u have the extra UDF's needed for what I am about to display.

The code below is very quick and dirty.

The point of interrest are these lines:

#Include <GuiComboBox.au3> ; Needed for the command below

and

_GUICtrlComboBox_GetCurSel($combo) ; Where $combo ofcourse if the variable where the handle of your combobox is stored

#include <GUIConstants.au3>
#Include <GuiComboBox.au3>

$gui = guicreate("titel",200, 200)
$combo = GUICtrlCreateCombo("", 10, 10, 175, 20)
GUICtrlSetData(-1, "line1|line2|line 3|line 4|line 5|line 6")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $combo Then msgbox(0,"",_GUICtrlComboBox_GetCurSel($combo))
    Sleep(20)
Wend

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Share this post


Link to post
Share on other sites
Xtupid

Sorry ! I don't understand ( you can see my name for the reason :) )

This:

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

What i've to do here?

With this example, it will drop down 6 line, right? For example, when I chose line 3. I want display a message box : " line 3"

(OMG! I haven't enought vocabulary to descriptive my trouble >"< !!! I hope you can understand what i am talking about :()

Thanks Triblade ( when i reply, i haven't refresh this page )

Edited by Xtupid

Please don't angry if I wrote something wrong because my English vocabulary is very little....

Share this post


Link to post
Share on other sites
Triblade

Sorry ! I don't understand ( you can see my name for the reason :) )

This:

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

What i've to do here?

With this example, it will drop down 6 line, right? For example, when I chose line 3. I want display a message box : " line 3"

(OMG! I haven't enought vocabulary to descriptive my trouble >"< !!! I hope you can understand what i am talking about :()

Thanks Triblade ( when i reply, i haven't refresh this page )

First of all, is your problem solved?

Second:

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

This piece means:

Loop between Do and Until, until you press the close button of the GUI

Second, if you edit the line in my code

from:

If $msg = $combo Then msgbox(0,"",_GUICtrlComboBox_GetCurSel($combo))

to:

If $msg = $combo Then msgbox(0,"","You chose line: " & _GUICtrlComboBox_GetCurSel($combo))

Then you get "You chose Line: " <line number>


My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

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  

×