Sign in to follow this  
Followers 0
d2a007

Looking For Help On Combo Boxes

6 posts in this topic

Hi guys

I'm back to trying to find time to make little programs for fun.

Currently I'm trying to make a program that will use combo boxes and I'm completly lost. The layout is picking an item type then based on that a class then an item and then a modification to that item. In the end I'll add one more combo box and end up with a total of 5. As you select items in the top box the second box will populate based on the first selection and so on down to the 5th. Here is the Func that i have so far that's not working:

$Combo_1 = GuiCtrlCreateCombo("Select", 180, 50, 120, 21)
$Combo_1 = GUICtrlSetData(-1,"Weapon|Armor","Select")
GUICtrlSetOnEvent(-1, "COMBO1Selected")
$Combo_2 = GuiCtrlCreateCombo("Select Above", 180, 80, 120, 21)

Func COMBO1Selected()
    $ComboText_1 = Guictrlread($Combo_1)
    If $ComboText_1 = "Armor" Then GUICtrlSetData(4,"|Select|Helm|Body Armor|Shield", "Select")
    If $ComboText_1 = "Weapon" Then GUICtrlSetData(4,"|Select|Axes|Bows|Crossbows|Daggers|Maces|Polearms|Scepters|Spears|Staves|Swords|Wands", "Select")
    MsgBox(0, "Testing", "The read is " & $ComboText_1)

I think I'm not using the read correctly I think, but over the last 30 minutes I can't figure out how I'm doing it wrong. No matter what I select it puts the weapons in the second combo box. Also the msgbox s just so I could see what's in "$ComboText_1" and it always outputs "0".

Any help would be great

Thanks,

d2a007

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$Combo_1 = GuiCtrlCreateCombo("Select", 180, 50, 120, 121)
GUICtrlSetData(-1,"Weapon|Armor","Select");********** this is the line that had to be changed ******
GUICtrlSetOnEvent(-1, "COMBO1Selected")
$Combo_2 = GuiCtrlCreateCombo("Select Above", 180, 80, 120, 121)

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try this:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", True)

GUICreate("Test")
GUISetOnEvent($GUI_EVENT_CLOSE, "Gui_Close")
$Combo_1 = GUICtrlCreateCombo("Select", 180, 50, 120, 21)
GUICtrlSetData(-1, "Weapon|Armor", "Select")
GUICtrlSetOnEvent(-1, "COMBO1Selected")
$Combo_2 = GUICtrlCreateCombo("Select Above", 180, 80, 120, 21)
GUISetState()

While 1
    Sleep(250)
WEnd

Func COMBO1Selected()
    $ComboText_1 = GUICtrlRead($Combo_1)
    If $ComboText_1 = "Armor" Then GUICtrlSetData($Combo_2, "|Select|Helm|Body Armor|Shield", "Select")
    If $ComboText_1 = "Weapon" Then GUICtrlSetData($Combo_2, "|Select|Axes|Bows|Crossbows|Daggers|Maces|Polearms|Scepters|Spears|Staves|Swords|Wands", "Select")
EndFunc ;==>COMBO1Selected

Func Gui_Close()
    Exit
EndFunc ;==>Gui_Close

Edit: minor change in script

Edited by big_daddy

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", True)

GUICreate("Test")
GUISetOnEvent($GUI_EVENT_CLOSE, "Gui_Close")
$Combo_1 = GUICtrlCreateCombo("Select", 180, 50, 120, 21)
$Combo_1 = GUICtrlSetData(-1, "Weapon|Armor", "Select")
GUICtrlSetOnEvent(-1, "COMBO1Selected")
$Combo_2 = GUICtrlCreateCombo("Select Above", 180, 80, 120, 21)
GUISetState()

While 1
    Sleep(250)
WEnd

Func COMBO1Selected()
    $ComboText_1 = GUICtrlRead($Combo_1)
    If $ComboText_1 = "Armor" Then GUICtrlSetData($Combo_2, "|Select|Helm|Body Armor|Shield", "Select")
    If $ComboText_1 = "Weapon" Then GUICtrlSetData($Combo_2, "|Select|Axes|Bows|Crossbows|Daggers|Maces|Polearms|Scepters|Spears|Staves|Swords|Wands", "Select")
EndFunc ;==>COMBO1Selected

Func Gui_Close()
    Exit
EndFunc ;==>Gui_Close
try again big_daddy

$Combo_1 = GUICtrlSetData(-1, "Weapon|Armor", "Select")

change to

GUICtrlSetData(-1, "Weapon|Armor", "Select")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

try again big_daddy

$Combo_1 = GUICtrlSetData(-1, "Weapon|Armor", "Select")

change to

GUICtrlSetData(-1, "Weapon|Armor", "Select")
Lol, I didn't even notice that. It still works though.

Share this post


Link to post
Share on other sites

Thank you Big_daddy & Gafrost, worked like a charm!

d2a007

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  
Followers 0