?
Solved

Using an ArrayList to Hold Form References

Posted on 2013-05-15
2
Medium Priority
?
193 Views
Last Modified: 2013-06-05
Experts,

For a project I have several tables that I want to provide access to for the user.  I would like to have each form load in a Panel on the main form.  I was thinking of using an ArrayList do do this wth the following dimensions:

14 x 3 = 14 Forms by three Properties

The properties would be:

Form Reference
Form Name as String
Form Visible as Boolean

I thought using an ArrayList would be the best way to do this, but would this eat up resources to quickly?

If not an ArrayList what would you suggest?

Thanks!
0
Comment
Question by:Peter Allen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 600 total points
ID: 39169403
No, this would not "eat" up too much resources.  It's a drop in the bucket...

I recommend you create a Class to hold those values:
    Public Class FormData
        Public Reference As Form
        Public Name As String
        Public Visible As Boolean
    End Class

Open in new window


Then use a List(Of FormData) to hold those values:
Public Class Form1

    Public Class FormData
        Public Reference As Form
        Public Name As String
        Public Visible As Boolean
    End Class

    Private OpenedForms As New List(Of FormData)

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim frm As New Form
        frm.Text = "Hello"
        frm.Show()

        Dim fd As New FormData
        fd.Reference = frm
        fd.Name = frm.Text
        fd.Visible = True
        OpenedForms.Add(fd)
    End Sub

End Class

Open in new window

0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 400 total points
ID: 39170229
As any object based on a class instead of a structure, a Form is a reference object. That means that when you pass a form from one place to another, you are not passing a copy with all the properties in it, you are simply passing the reference, a pointer, the address where the form is in memory.

Simply add your forms to the array list, and all you will have in memory, other than the relatively small overhead needed for the few properties of the ArrayList itself (such as Count), will be 14 pointers (14 x 4 bytes or 14 x 8 bytes depending on whether you are running in 32-bits or 64-bits). And you will not be limited to the 3 properties, but to all the propeties of the forms.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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