Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

help me to create an array of controls at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Philip - 29 Jan 2007 17:05 GMT
Hi,

I have built a control consisting of two listboxes and a button. The idea is
that I populat ethe list on the left, and the user selects items that are
added to the listbox on the right. This list is exposed by my user control as
an array.

I want to bve able to add multiple controls at runtime (basically one for
each parameter of a stored procedure that the user will select from a
drop-down).

I tried to test this idea having new controls added to an array but I get an
error 'Object reference not set to an instance of an object'

How should I do this in VB.NET please?

here is the code I have:

       Dim tb As New TabPage
       Dim ls() As ListSelector
       Static count As Int16

       tabParams.TabPages.Add(tb)
       tb.Text = count

       Dim listSel As New ListSelector

       ls(count) = listSel

       tb.Controls.Add(ls(count))

       With ls(count)
           .DataList = Nothing
           .Location = New System.Drawing.Point(16, 8)
           .Name = "ListSelector1"
           .SelectedList = Nothing
           .Size = New System.Drawing.Size(368, 144)
           .TabIndex = 0
       End With

       count = count + 1
ClayB - 30 Jan 2007 11:06 GMT
If you want ls to dynamically grow, then you probably need to use an
ArrayList (or a Generic List<> if this is available in VB.NET 2.0).

Dim Is As New ArrayList

'....

Is.Add(listSel)

===============================
Clay Burch
Syncfusion, Inc.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.