"Control arrays"
"Control arrays"
"Control arrays"
"Control arrays"
"Control arrays"
"Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays"
"Control arrays" "Control arrays"
"Control arrays"
Go Back  Xtreme Visual Basic Talk > > > "Control arrays"


Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2008, 05:42 AM
jimseng jimseng is offline
Freshman
 
Join Date: Nov 2007
Posts: 38
Default "Control arrays"


Hi
I have read through the many control array posts on the web and they all seem to point to how to add controls and a handler to receive an event from the control. I haven't found out how to delete controls or change their properties:

Private Sub Labelevent(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim MyLabelevent As Label
MyLabelevent = CType(sender, Label)
MyLabelevent.BackColor = System.Drawing.Color.Red
End Sub


Private Sub createLBL(ByVal index As Integer)
Dim i As Integer
For i = 1 To 5
Dim Mylabel As New Label()
Mylabel.Location = New System.Drawing.Point(250, 40 + i * 40)
Mylabel.Size = New System.Drawing.Size(100, 20)
Mylabel.Text = CStr("Label " & i)
Mylabel.Name = CStr("Label" & i)
Me.Controls.Add(Mylabel)
AddHandler Mylabel.Click, AddressOf Me.Labelevent
Next

End Sub

This is all great and I have the labels doing their stuff but how would I change their text in a loop from another procedure or delete (unload in old vb6)?

Thanks
Reply With Quote
  #2  
Old 03-29-2008, 06:03 AM
Qua's Avatar
Qua"Control arrays" Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

When you add a control to the form, it is stored for you in the control collection in the form. This means that you can access it anytime by using:
Code:
FormName.Controls("LabelName").PRopety = Value
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #3  
Old 03-29-2008, 06:26 AM
jimseng jimseng is offline
Freshman
 
Join Date: Nov 2007
Posts: 38
Default

Hey thanks.
I was nearly there but I wa using me.controls.remove("labelname") instead of the .dispose
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
"Control arrays"
"Control arrays"
"Control arrays" "Control arrays"
"Control arrays"
"Control arrays"
"Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays" "Control arrays"
"Control arrays"
"Control arrays"
 
"Control arrays"
"Control arrays"
 
-->