|
-
Nov 6th, 2009, 11:12 AM
#1
Thread Starter
Member
Custom Control Question *(Resolved)*
Hello,
I am creating an array of customer controls by doing the following:
Dim CtlLosArray(150) As Control
Then I'm setting up the first control in the array like this:
CtlLosArray(1) = New ShieldLOSInfobox
CtlLosArray(1).Location = New Point(0, 0)
CtlLosArray(1).Visible = True
CtlLosArray(1).Show()
CtlLosArray(1).Name = "Label1"
Me.pnlLOS.Controls.Add(CtlLosArray(1))
Now on this custom control I have a panel and a few text boxes and as you can see I may be adding about 150 of these custom controls.
What I am wanting to do is to be able to access that control then the item on that control based on the array. something like the following:
CtlLosArray(1).Controls.Item(Panel1).backcolor = Color.Yellow
But the above does not work 
Anyone have any ideas on how I'm supposed to format this last line? so I can access a specific item on the customer control within the array?
thanks so much for your assistance.
Mythos
Last edited by Mythos44; Nov 6th, 2009 at 01:31 PM.
Reason: Resolved
-
Nov 6th, 2009, 11:23 AM
#2
Re: Custom Control Question
First of all, arrays start at 0 not 1, so you are setting up the second item there, not the first.
I assume the 150 controls are all of the same type 'SheildLOSInfobox'?
So you just need to cast your control to that type to access its properties. Here is an example:
Code:
Dim CtlLosArray(150) As ShieldLOSInfobox
CtlLosArray(0) = New ShieldLOSInfobox
CtlLosArray(0).Location = New Point(0, 0)
CtlLosArray(0).Visible = True
CtlLosArray(0).Show()
CtlLosArray(0).Name = "Label1"
Me.pnlLOS.Controls.Add(CtlLosArray(0))
DirectCast(Me.pnlLOS.Controls("Label1"), ShieldLOSInfobox).Textbox1.Text = "HELLO WORLD"
Note this code assumes your custom control has a textbox called textbox1 on it. This is just an example, so modify that for the specific controls you do have on your custom control.
-
Nov 6th, 2009, 01:30 PM
#3
Thread Starter
Member
Re: Custom Control Question
You are AWESOME!!! thank you so much!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|