Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

array of textboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    array of textboxes

    i have lists with 10 and more textboxes for example test1.text, test2.text
    ....i want as i could do in vb6 with just a copy-paste of the same textbox, to
    have an array like test(1).text, test(2).text and to change the contents
    with a loop like "for"...is there any simple way to solve it?
    thank you in advance
  • Chris Podmore

    #2
    RE: array of textboxes

    John,

    http://www.codeproject.com/vb/net/Control_Arrays.asp might point you in the
    right direction.

    Chris.

    "John" wrote:
    [color=blue]
    > i have lists with 10 and more textboxes for example test1.text, test2.text
    > ...i want as i could do in vb6 with just a copy-paste of the same textbox, to
    > have an array like test(1).text, test(2).text and to change the contents
    > with a loop like "for"...is there any simple way to solve it?
    > thank you in advance[/color]

    Comment

    • Cor Ligthert

      #3
      Re: array of textboxes

      John,

      It is so easy when you know this, however before you know it hard to find.

      Dim test As Textbox() = Textbpx() {Textbox1, Textobox2}

      :-)

      I hope this helps?

      Cor

      "John" <John@discussio ns.microsoft.co m>
      [color=blue]
      >i have lists with 10 and more textboxes for example test1.text, test2.text
      > ...i want as i could do in vb6 with just a copy-paste of the same textbox,
      > to
      > have an array like test(1).text, test(2).text and to change the contents
      > with a loop like "for"...is there any simple way to solve it?
      > thank you in advance[/color]


      Comment

      • Elysee

        #4
        Re: array of textboxes

        John. it easy.

        Create either you textboxes in design time or in runtime.
        let suppse test1,test2, test3....
        assign a tag to each textbox.

        in new sub of the form do this:

        Dim arrText as new arraylist

        add all textboxes and others objects you want into the the array list

        arrText.add test1
        arrText.add test2.


        Now, to use in your application

        dim t as textbox
        For each Obj in arrText
        if typeof(Obj) is TextBox then
        t=ctype(Obj,tex tbox)
        if t.tag="1" then
        'dosomething
        end if
        end if
        next


        "John" <John@discussio ns.microsoft.co m> wrote in message
        news:8EB5B79F-3BF1-4813-9AE3-E10FD8C4D6A1@mi crosoft.com...[color=blue]
        > i have lists with 10 and more textboxes for example test1.text,[/color]
        test2.text[color=blue]
        > ...i want as i could do in vb6 with just a copy-paste of the same textbox,[/color]
        to[color=blue]
        > have an array like test(1).text, test(2).text and to change the contents
        > with a loop like "for"...is there any simple way to solve it?
        > thank you in advance[/color]


        Comment

        Working...