Solved

loading controls vb.net

Posted on 2006-07-17
1
166 Views
Last Modified: 2012-05-05
I had a vb6 application I am trying to convert.

I had a form, with a control array with one element.

I load the form, then reproduce the controls as I need them.

In this case, they are either text boxes or select boxes.

So if I wanted, I would display 5 of them across.

        If lastStep = 0 Then
            ctrlInputForm1(lastStep).Left = startLeft
            ctrlInputForm1(lastStep).Top = startTop
        Else
            Load ctrlInputForm1(lastStep)
            ctrlInputForm1(lastStep).Left = currentLeft
            ctrlInputForm1(lastStep).Top = currentTop
        end if

All I had to do was load the control with "Load" and it would work.

How can I do this with vb.net?

I need to be able to load controls named "ctrlInputForm" on the fly,
and refer to them somehow, in this case a control array.
0
Comment
Question by:jackjohnson44
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 17125448
The control array in this sense no longer exists in VB.Net...

The simplest solution would be to dynamically create new controls and add them to an ArrayList

    Private myTextBoxes As New ArrayList

    Private Sub Foo()
            Dim tb As New TextBox
            tb.Left = currentLeft
            tb.Top = currentTop
            myTextBoxes.Add(tb)
            Me.Controls.Add(tb)   ' or add it to whatever container you need such as "Panel1.Controls.Add(tb)"
    End Sub

You can check the number of items in the ArrayList using Count (or Length...I can't remember which) to determine how many items are already in the array list.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now