Sign in to follow this  
Followers 0
lordicast

GuiCtrlSetData with combobox

4 posts in this topic

Ok so i want to use the same GUICtrlCreatecombo to display 2 different data dropdowns ; Example

Problem is when i select water in also gives me the values of the rest of the forms

ie; water|fire|wind|earthSplash|Swim|Back","Forms

I want 1 at a time

CODE
$Forms = GUICtrlCreatecombo('Forms', 776, 144, 153, 25)

GUICtrlSetData($Forms,"water|fire|wind|earth","Forms")

$n2= GUICtrlCreateButton("Format", 776, 166, 50,25)

While 1

$Msg = GUIGetMsg()

Select

Case $msg = $n2

$whatnow = GUICtrlRead($Forms)

If GUICtrlRead($Forms) = 'water' Then hnote()

If GUICtrlRead($Forms) = 'back' Then bnote()

EndSelect

WEnd

Func hnote()

GUICtrlSetData($Forms,"Splash|Swim|Back","Splash")

EndFunc

Func bnote()

GUICtrlSetData($Forms,"water|fire|wind|earth","Forms")

EndFunc

Is this the way to do it or is there somthing more simple?


[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just use a GUICtrlSetData() to clear the combobox data before creating the new entries:

Func hnote()
GUICtrlSetData($Forms,"")
GUICtrlSetData($Forms,"Splash|Swim|Back","Splash")
EndFunc

Func bnote()
GUICtrlSetData($Forms,"")
GUICtrlSetData($Forms,"water|fire|wind|earth","Forms")
EndFunc
Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Ok so i want to use the same GUICtrlCreatecombo to display 2 different data dropdowns ; Example

Problem is when i select water in also gives me the values of the rest of the forms

ie; water|fire|wind|earthSplash|Swim|Back","Forms

I want 1 at a time

Is this the way to do it or is there somthing more simple?

You need to get in the habbit of posting working code... :)

Your problem is that GuiControlSetData() can only ADD items, not replace them.

But the UDF functions have handy things like _GuiCtrlComboBox_ResetContent():

#include <GuiConstants.au3>
#include <GuiComboBox.au3>
$hGUI = GUICreate("Test", 170, 85)
$Forms = GUICtrlCreateCombo('Forms', 10, 10, 150, 25)
$hForms = ControlGetHandle($hGUI, "", $Forms)
GUICtrlSetData($Forms, "water|fire|wind|earth", "Forms")
$n2 = GUICtrlCreateButton("Format", 35, 45, 100, 30)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
        Case $Msg = $n2
            $whatnow = GUICtrlRead($Forms)
            If GUICtrlRead($Forms) = 'water'  Then hnote()
            If GUICtrlRead($Forms) = 'back'  Then bnote()
    EndSelect
WEnd

Func hnote()
    _GUICtrlComboBox_ResetContent($hForms)
    GUICtrlSetData($Forms, "Splash|Swim|Back", "Splash")
EndFunc   ;==>hnote

Func bnote()
    _GUICtrlComboBox_ResetContent($hForms)
    GUICtrlSetData($Forms, "water|fire|wind|earth", "Forms")
EndFunc   ;==>bnote

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You need to get in the habbit of posting working code...

sorry bout that im horrible at posting code, this script is 50 functions deep and looks like a maze i forget about includes.

thanks for the advice.


[Cheeky]Comment[/Cheeky]

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