Results 1 to 5 of 5

Thread: Array Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    97

    Array Control

    Hello!

    Some small example how to create an Array of controls with its events and properties, example: TextBox, in runtime?

    It is for VB.NET Compact Framework

    Thank you :-)

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Array Control

    Hi,
    try something like
    Code:
    Dim ict As Integer
            Dim txtArr(5) As TextBox
            For ict = 0 To 5
                txtArr(ict) = New TextBox
                txtArr(ict).Text = "Box " & ict
                txtArr(ict).Tag = "Box" & ict
                txtArr(ict).Size = New System.Drawing.Size(100, 30)
                txtArr(ict).Location = New System.Drawing.Point(20, ict * 40)
                txtArr(ict).Visible = True
                Me.Controls.Add(txtArr(ict))
            Next
    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    97

    Re: Array Control

    Quote Originally Posted by petevick
    Hi,
    try something like
    Code:
    Dim ict As Integer
            Dim txtArr(5) As TextBox
            For ict = 0 To 5
                txtArr(ict) = New TextBox
                txtArr(ict).Text = "Box " & ict
                txtArr(ict).Tag = "Box" & ict
                txtArr(ict).Size = New System.Drawing.Size(100, 30)
                txtArr(ict).Location = New System.Drawing.Point(20, ict * 40)
                txtArr(ict).Visible = True
                Me.Controls.Add(txtArr(ict))
            Next
    Pete
    Very good!

    and events? example Click, GotFocus, LostFocus...

    Thank you Pete

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Array Control

    Hi,
    Code:
    AddHandler txtArr(ict).GotFocus, AddressOf txtArr_GotFocus
    ...
        Private Sub txtArr_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) 
    ...
        End Sub
    Not Tested

    Try it and see
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Array Control

    You can have the same handler handle the events for several different controls, so you don't necessarily have to make different functions for each control.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width