User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 402,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,146 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1290 | Replies: 3
Reply
Join Date: Oct 2006
Posts: 14
Reputation: lukis is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
lukis lukis is offline Offline
Newbie Poster

creating array for saving location of label

  #1  
May 15th, 2007
Hi there,

i need to create an array to save the location of labels on the form that are created at runtime. how can i do this please?

thanks

Luke
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 375
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 38
waynespangler waynespangler is offline Offline
Posting Whiz

Re: creating array for saving location of label

  #2  
May 15th, 2007
Your locations are already in the controls collection.
Reply With Quote  
Join Date: Oct 2006
Posts: 14
Reputation: lukis is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
lukis lukis is offline Offline
Newbie Poster

Re: creating array for saving location of label

  #3  
May 15th, 2007
but since they're being created at runtime i don't think it is saved in the controls.collection
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 375
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 38
waynespangler waynespangler is offline Offline
Posting Whiz

Re: creating array for saving location of label

  #4  
May 15th, 2007
Yes it is.
       Dim ctrl As New Label
        ctrl.Location = New Point(10, 30)
        ctrl.Visible = True
        ctrl.Text = "The first label"
        ctrl.Name = "Label1"
        Me.Controls.Add(ctrl)
        ctrl = New Label
        ctrl.Location = New Point(150, 30)
        ctrl.Visible = True
        ctrl.Text = "The second label"
        ctrl.Name = "Label2"
        Me.Controls.Add(ctrl)
To get the location:
        Dim ctrl As Label = Me.Controls.Item("label1")
        Dim ctrl1 As Label = Me.Controls.Item("label2")
        MessageBox.Show(ctrl.Location.ToString & "|" & ctrl1.Location.ToString)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 3:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC