Jump to content
SerLanceloth

Need Help with ComboBoxes

Recommended Posts

SerLanceloth

hello everyone i have been looking for help to set 3 comboboxes that work depending on each other (combo2 have diferent options depending on whats selected on combo1, same with comobo 3 and 2), once the level are selected to set text into an edit box depending on the selected level

btw if can explain with note would be awesome, im still learning :D 

Edited by SerLanceloth

Share this post


Link to post
Share on other sites
galan2015

 

Case $Combo4; Stany
            $ReadCombo = GUICtrlRead($Combo4)
            if $ReadCombo = "Your 1 Option" then
            $Data = "Moto|Pish|Helo" ; data to change
            GUICtrlSetData($Combo5,$Data) ; change data in $Combo5
        ElseIf $ReadCombo = "Your 2 Option" then
            $Data = "Helo|Moto|Pish" 
            GUICtrlSetData($Combo5,$Data)
        Endif

 

I add this into my case in while :D

Edited by galan2015

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

Welcome to the AutoIt forums.

I explained how this might be done in this thread.  Please ask again if you still have any questions after reading the code.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
galan2015

SerLanceloth,

Welcome to the AutoIt forums.

I explained how this might be done in this thread.  Please ask again if you still have any questions after reading the code.

M23

​What about mine solution?

Share this post


Link to post
Share on other sites
Melba23

galan2015,

When I started composing my post you had not yet posted yours - it happens a lot so please do not think anything of it.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
galan2015

I asked if my way is good?

Share this post


Link to post
Share on other sites
SerLanceloth

I add this into my case in while

 

thnks im goin to try it and see if i can make it work the way i need 

Share this post


Link to post
Share on other sites
kylomas

SirLanceloth,

An example...

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

Local $hGui010 = GUICreate('Combo Demo', 340, 200)
Local $cCombo1 = GUICtrlCreateCombo('', 10, 30, 100, 50)
Local $cCombo2 = GUICtrlCreateCombo('', 120, 30, 100, 50)
Local $cCombo3 = GUICtrlCreateCombo('', 230, 30, 100, 50)

; combo1 string
Local $sCombo1 = '|Breakfast|Lunch|Dinner'
; combo2 array
Local $aCombo2[3][5] = [ _
        ['Breakfast', 'Eggs', 'Sausage', 'Biskets'], _
        ['Lunch', 'Hamburger', 'Daily Special', 'Meat Loaf'], _
        ['Dinner', 'Steak', 'Fish', 'Lasagna']]
; combo3 array
Local $aCombo3[9][5] = [ _
        ['Eggs', 'Over Easy', 'Scrambled', 'Sunny Side Up'], _
        ['Sausage', 'Links', 'Patties'], _
        ['Biskets', 'Toasted', 'Buttered'], _
        ['Hamburger', 'Fries', 'Soup', 'Salad'], _
        ['Daily Special', 'Soup', 'Salad'], _
        ['Meat Loaf', 'Soup', 'Salad', 'Potato'], _
        ['Steak', 'Rare', 'Medium', 'Well'], _
        ['Fish', 'Cod', 'Pollock', 'Perch'], _
        ['Lasagna', 'Soup', 'Salad', 'Potato']]

Local $sCombo2, $sCombo3

GUICtrlSetData($cCombo1, $sCombo1)
GUICtrlSetData($cCombo1, _GUICtrlComboBox_GetListArray($cCombo1)[1])

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        Case $cCombo1
            For $i = 0 To UBound($aCombo2) - 1
                If StringStripWS(GUICtrlRead($cCombo1), 3) = $aCombo2[$i][0] Then
                    $sCombo2 = '|'
                    For $j = 1 To UBound($aCombo2, 2)
                        If $aCombo2[$i][$j] = '' Then ExitLoop
                        $sCombo2 &= $aCombo2[$i][$j] & '|'
                    Next
                EndIf
            Next
            GUICtrlSetData($cCombo2, $sCombo2)
            GUICtrlSetData($cCombo2, _GUICtrlComboBox_GetListArray($cCombo2)[1])
        Case $cCombo2
            For $i = 0 To UBound($aCombo3) - 1
                If StringStripWS(GUICtrlRead($cCombo2), 3) = $aCombo3[$i][0] Then
                    $sCombo3 = '|'
                    For $j = 1 To UBound($aCombo3, 2)
                        If $aCombo3[$i][$j] = '' Then ExitLoop
                        $sCombo3 &= $aCombo3[$i][$j] & '|'
                    Next
                EndIf
            Next
            GUICtrlSetData($cCombo3, $sCombo3)
            GUICtrlSetData($cCombo3, _GUICtrlComboBox_GetListArray($cCombo3)[1])
        Case $cCombo3
            ConsoleWrite('You ordered ' & GUICtrlRead($cCombo1) & ', ' & GUICtrlRead($cCombo2) & ', ' & GUICtrlRead($cCombo3) & @CRLF)
    EndSwitch
WEnd

Similar to what M23 posted above except that the data for the combo controls is not externalized.  As you can see, organizing your data and data relationships is the biggest part of this effort.  It is always better to manage the data externally for ease of maintenance and flexibility with updates.  I posted this as an example of how the controls might be managed.

You will need to understand arrays for this code to make any sense to you.  As a new user I would recommend searching the Wiki for various tutorials and reading the Help file.

kylomas 

 

 

 

Edited by kylomas
code not tidied

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
SerLanceloth

Similar to what M23 posted above except that the data for the combo controls is not externalized.  As you can see, organizing your data and data relationships is the biggest part of this effort.  It is always better to manage the data externally for ease of maintenance and flexibility with updates.  I posted this as an example of how the controls might be managed.

You will need to understand arrays for this code to make any sense to you.  As a new user I would recommend searching the Wiki for various tutorials and reading the Help file.

kylomas 

 

​how would it work on a global? i pretty much need everything to work around the levels selected on the combos

Share this post


Link to post
Share on other sites
SerLanceloth

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>



$Form1 = GUICreate("Form1", 355, 172, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 8, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

                   GUICtrlSetData($Combo1, "Item 2|Item 3", "")
$Combo2 = GUICtrlCreateCombo("Combo2", 168, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

                   GUICtrlSetData($Combo2, "Item 2|Item 3", "")
$Edit1 = GUICtrlCreateEdit("", 8, 48, 185, 89)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

what im looking for is some way to do, this are different options for different levels, example if combo1 == item1 then combo2 options are 1|2|3, but if combo1 == item2 then combo2 options are 4|5|6, and depending on the levels selected edit1 must have text inserted

if combo1 == item2 then combo2  GUICtrlSetData($Combo2, "Item 2|Item 3", "")

if combo2 == item 3 then GUICtrlSetData($Edit1, "this text must be inserted", 1)

please help, and explain if possible im new on autoit but im really looking forward to dominate it

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

You already have a thread running on this - please stick to just the one at a time. Threads merged.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

This script does what you said you required:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

$Form1 = GUICreate("Form1", 355, 172, 192, 124)

$Combo1 = GUICtrlCreateCombo("", 8, 8, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "Item 2|Item 3")
$Combo2 = GUICtrlCreateCombo("", 168, 8, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetState($Combo2, $GUI_DISABLE)
$Edit1 = GUICtrlCreateEdit("", 8, 48, 185, 89)
GUICtrlSetData($Edit1, "Edit1")

GUISetState(@SW_SHOW)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Item 2"
                    GUICtrlSetData($Combo2, "|Item 1|Item 2|Item 3")
                    GUICtrlSetState($Combo2, $GUI_ENABLE)
                Case "Item 3"
                    GUICtrlSetData($Combo2, "|Item 4|Item 5|Item 6")
                    GUICtrlSetState($Combo2, $GUI_ENABLE)
            EndSwitch

        Case $Combo2
            If GUICtrlRead($Combo2) = "Item 3" Then
                GUICtrlSetData($Edit1, "this text must be inserted", 1)
            EndIf

    EndSwitch
WEnd

As it is so simple to follow, I have not added any comments, but please do ask if you have any questions.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
SerLanceloth

​thanks melba this is exactly what I need it, and nice programing style

Share this post


Link to post
Share on other sites
Melba23

SerLanceloth,

Delighted I could help. But when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
SerLanceloth

hey melba, con the combobox im using too many items, and I will need a scroll either with the mouse or a bar in the side, do you know, how can I do it?

Share this post


Link to post
Share on other sites
SerLanceloth

nevermind I found my way :D thnks

Share this post


Link to post
Share on other sites
SerLanceloth

hello im back, im still working on my code and I need a new function that set the data of the buttons depending of what is selected on the combo

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 229, 295, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 8, 8, 169, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
   GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)


While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit

 EndSwitch
WEnd

 

 

here is like an idea of flow of what im looking for
if GUICtrlRead($combo1) = "Item 1" Then $Button1 sets edit1 data to yes and $button2 sets edit1 data to no
   if GUICtrlRead($combo1) = "Item 2" Then $Button1 sets edit1 data to yes2 and $button2 sets edit1 data to no2
   if GUICtrlRead($combo1) = "Item 3" Then $Button1 sets edit1 data to yes3 and $button2 sets edit1 data to no3

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

×