Solved

how to create an object array with a child object.

Posted on 2009-04-14
4
183 Views
Last Modified: 2012-05-06
Hi All!

Ok.. I have a small loop that creates a new PANEL, After each panel is created I also am creating a new LABEL within that panel.. as its child.

The problem is I only get one LABEL in the first PANEL?

Im stumped..
Thanks in Advance..

Code is below..
Dim panelx(10) As Panel
        Dim labelx(10) As Label
 
        CNT = 0
        Dim looper
        For looper = 1 To 9
 
            panelx(looper) = New Panel
            labelx(looper) = New Label
 
            panelx(looper).BorderStyle = BorderStyle.FixedSingle
            panelx(looper).BackColor = Color.Pink
            panelx(looper).Width = 123 * looper
            panelx(looper).Height = 123
            panelx(looper).Location = New Point(10, 10)
 
 
            Me.Controls.Add(panelx(looper))
 
 
            ToolTip1.SetToolTip(panelx(looper), looper)
            ToolTip1.SetToolTip(labelx(looper), ".." & looper)
 
            labelx(looper).Location = New Point(-1, -2)
            labelx(looper).MinimumSize = New Size(24, 24)
            labelx(looper).Size = New Size(24, 24)
            labelx(looper).TextAlign = ContentAlignment.MiddleCenter
            labelx(looper).BackColor = Color.GreenYellow
            labelx(looper).Text = looper.ToString
            
panelx(looper).Controls.Add(labelx(looper))
 
        Next looper

Open in new window

vb.jpg
0
Comment
Question by:jellydeal
[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
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 24138374
Your code is working and labels are inserted, but overlapping panels.

Replace the hnasr commented lines and check:

            panelx(looper).Width = 123 '* looper ==== hnasr commnted the multiplication
            panelx(looper).Height = 123
            panelx(looper).Location = New Point(10 + (looper-1) * 123, 10) 'hnasr changed the left of the panel
0
 

Author Closing Comment

by:jellydeal
ID: 31569860
Thanks hnasr..
Too close to the trees to see thw woods and all that!
Thanks for your help,
much appreciated.
Kindest regards
Barry
0
 
LVL 30

Expert Comment

by:hnasr
ID: 24141019
You are welcome!
0
 

Author Comment

by:jellydeal
ID: 24145772
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Output in PHP throwing alignment of data off issue 12 76
Collapse and expand table in Word 2010 2 163
Developing a front end to SPLUNK 1 111
Developers / Staff Setup 10 48
This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 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