##Help me plz: 15 ComboBox on a form----how to refer to them in a For loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SkyTV
    New Member
    • Nov 2006
    • 5

    ##Help me plz: 15 ComboBox on a form----how to refer to them in a For loop

    i have got 15 combo Boxs on the form
    they are named cbo1 - cbo15

    the following works just fun
    strY= cbo1.Text;

    but i wanna learn the for loop way to do it....
    i have tried many times...can't figure this out.



    how can i refer to the 15 combo boxes in the loop.....

    for (int intI =1 ; intI < 16; intI ++)
    {
    ComboBox cbo = ComboBox (cbo+(intI).ToS tring()) ;
    strY = cbo.Text;
    }

    error message: 'System.Windows .Forms.ComboBox ' denotes a 'class' which is not valid in the given context


    thx a lot....

    Regards

    Sky
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    #2
    hello

    as you want use a for loop for controls yopu have to use foreach(){} syntax

    helps you.first take an array of controls and then try to loop them


    regards

    nmsreddy

    Comment

    Working...