Sign in to follow this  
Followers 0
bohmam

Help - chose from combo list -

3 posts in this topic

Hello guys

what is wrong in these code

#include <GUIConstantsEx.au3>

$hGUI=GUICreate("COMBO" , 200 , 200 )
$hEDIT=GUICtrlCreateEdit("",10,50,150,115)

$hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
GUICtrlSetData($hCOMBO , "1|2|3")



GUISetState()

combo()


    

 Func combo()
    
    
    
    $hGUI=GUICreate("COMBO" , 200 , 200 )
    $hEDIT=GUICtrlCreateEdit("",10,50,150,140)

    $hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
    GUICtrlSetData($hCOMBO , "1|2|3")


    
While 1 
    
    $msg= GUIGetMsg()
    if $msg= $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    
    $return=GUICtrlRead($hCOMBO)
    
            Switch $return
                
                Case "1"
                    GUICtrlSetData($hEDIT, " The number you are chose is (1) " )
                    
                Case "2"
                    GUICtrlSetData($hEDIT, " The number you are chose is (2) " )
                    
                Case "3"
                    GUICtrlSetData($hEDIT, " The number you are chose is (3) " )
                    
            EndSwitch
    
WEnd
EndFunc

I'm want if I'm chose number from the combo list then print text in the edit space

but the code is not work correctly

wait your help

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
$hGUI=GUICreate("COMBO" , 200 , 200 )
$hEDIT=GUICtrlCreateEdit("",10,50,150,115)

$hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
GUICtrlSetData($hCOMBO , "1|2|3")





    $hGUI=GUICreate("COMBO" , 200 , 200 )
    $hEDIT=GUICtrlCreateEdit("",10,50,150,140)

    global $hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
    GUICtrlSetData($hCOMBO , "1|2|3")

GUISetState()


While 1

    $msg= GUIGetMsg()
    if $msg= $GUI_EVENT_CLOSE Then
        ExitLoop
    elseif $msg = $hCOMBO then
        _changecombo()
    EndIf



WEnd

Func _changecombo()
        $return=_GUICtrlComboBox_GetCurSel($hCOMBO)

            Switch $return

                Case 1
                    GUICtrlSetData($hEDIT, " The number you are chose is (1) " )

                Case 2
                    GUICtrlSetData($hEDIT, " The number you are chose is (2) " )

                Case 3
                    GUICtrlSetData($hEDIT, " The number you are chose is (3) " )

            EndSwitch

EndFunc

Edit:

To avoid flickering text in input-text, place your Switchmethod only when the combo changes.

Edited by notsure

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
$hGUI=GUICreate("COMBO" , 200 , 200 )
$hEDIT=GUICtrlCreateEdit("",10,50,150,115)

$hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
GUICtrlSetData($hCOMBO , "1|2|3")





    $hGUI=GUICreate("COMBO" , 200 , 200 )
    $hEDIT=GUICtrlCreateEdit("",10,50,150,140)

    global $hCOMBO=GUICtrlCreateCombo("Chose number" , 10 , 10 , 150 )
    GUICtrlSetData($hCOMBO , "1|2|3")

GUISetState()


While 1

    $msg= GUIGetMsg()
    if $msg= $GUI_EVENT_CLOSE Then
        ExitLoop
    elseif $msg = $hCOMBO then
        _changecombo()
    EndIf



WEnd

Func _changecombo()
        $return=_GUICtrlComboBox_GetCurSel($hCOMBO)

            Switch $return

                Case 1
                    GUICtrlSetData($hEDIT, " The number you are chose is (1) " )

                Case 2
                    GUICtrlSetData($hEDIT, " The number you are chose is (2) " )

                Case 3
                    GUICtrlSetData($hEDIT, " The number you are chose is (3) " )

            EndSwitch

EndFunc

Edit:

To avoid flickering text in input-text, place your Switchmethod only when the combo changes.

Thanks alot now all thing is OK

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