Solved

loading controls vb.net

Posted on 2006-07-17
1
168 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 70
VB.Net - Get ColumnNames of SQL Table 4 11
Get number of Files in Directory and Sub Directories 2 40
vb.net class 3 12
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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