Jump to content

Drop-down list


KatoXY
 Share

Recommended Posts

Using your arrays

Global $sList1 = ""
Global $aArray0[5] = [1,2,3,4,5]    ;VALUE LIST0
Global $aArray1[5] = [6,7,8,9,10]   ;VALUE LIST1

If GUICtrlRead($Box1) = $GUI_CHECKED Then
    $sList1 = ""
    For $i = 0 To UBound($aArray0) - 1
        $sList1 &= "|" & $aArray0[$i]
    Next
EndIf
If GUICtrlRead($Box2) = $GUI_CHECKED Then
    $sList1 = ""
    For $i = 0 To UBound($aArray1) - 1
        $sList1 &= "|" & $aArray1[$i]
    Next
EndIf

Or using a modular function

Global $sList1 = ""
Global $aArray0[5] = [1,2,3,4,5]    ;VALUE LIST0
Global $aArray1[5] = [6,7,8,9,10]   ;VALUE LIST1

If GUICtrlRead($Box1) = $GUI_CHECKED Then $sList1 = SetList($aArray0)
If GUICtrlRead($Box2) = $GUI_CHECKED Then $sList1 = SetList($aArray1)

Function SetList($aArray)
    If Not UBound($aArray) Then Return ""
    Local $sList = ""
    For $i = 0 To UBound($aArray) - 1
        $sList &= "|" & $aArray[$i]
    Next
    Return $sList
EndFunction

 

many ways to skin this cat

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 255, 253, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 48, 65, 17)  ; IF RADIO1 SELECTED LIST0 IS SELECTED
$Radio2 = GUICtrlCreateRadio("Radio2", 128, 48, 65, 17)  ;IF RADIO2 SELECTED LIST1 IS SELECTED
$Group1 = GUICtrlCreateGroup("POS", 24, 24, 177, 49)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sList1 = ""
Global $aArray0[5] = [1,2,3,4,5]    ;VALUE LIST0
Global $aArray1[5] = [6,7,8,9,10]   ;VALUE LIST1



Global $hCombo = GUICtrlCreateCombo("", 100, 148, 153, 25)

GUISetState()

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

 Case  $Radio1

If GUICtrlRead($Radio1) = $GUI_CHECKED Then $sList1 = SetList($aArray0)
GUICtrlSetData($hCombo, $sList1)

case  $Radio2

If GUICtrlRead($Radio2) = $GUI_CHECKED Then $sList1 = SetList($aArray1)
GUICtrlSetData($hCombo, $sList1)




    EndSwitch
WEnd




Func SetList($aArray)
    If Not UBound($aArray) Then Return ""
    Local $sList = ""
    For $i = 0 To UBound($aArray) - 1
        $sList &= "|" & $aArray[$i]
      Next
    Return $sList
EndFunc

 

Edited by antonioj84
error
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 255, 253, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 48, 65, 17)  ; IF RADIO1 SELECTED LIST0 IS SELECTED
$Radio2 = GUICtrlCreateRadio("Radio2", 128, 48, 65, 17)  ;IF RADIO2 SELECTED LIST1 IS SELECTED
$Group1 = GUICtrlCreateGroup("POS", 24, 24, 177, 49)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sList1 = ""
Global $aArray0[5] = [1,2,3,4,5]    ;VALUE LIST0
Global $aArray1[5] = [6,7,8,9,10]   ;VALUE LIST1



$hCombo = GUICtrlCreateCombo("", 100, 148, 153, 25)
; And fill it
GUICtrlSetData($hCombo, $sList1)

GUISetState()

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Radio1
            If GUICtrlRead($Radio1) = $GUI_CHECKED Then
    $sList1 = ""
    For $i = 0 To UBound($aArray0) - 1
        $sList1 &= "|" & $aArray0[$i]
        GUICtrlSetData($hCombo, $sList1) ;fill it
    Next
EndIf

        Case $Radio2
        If GUICtrlRead($Radio2) = $GUI_CHECKED Then
    $sList1 = ""
    For $i = 0 To UBound($aArray1) - 1
        $sList1 &= "|" & $aArray1[$i]
        GUICtrlSetData($hCombo, $sList1) ; fill it
    Next
EndIf


    EndSwitch
WEnd

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...