|
-
Dec 8th, 2004, 05:19 AM
#1
Thread Starter
Fanatic Member
dynamicly add my custom control
hi all i have made a control which is just a ui feature
however i would like to create the UI Control ex number of times in my form
i guess something like this
Dim HealthCtl As Control
For i As Integer = 1 To 5
HealthCtl = New HB_Server.Health
HealthCtl.Name = "HealthCtl" & i
HealthCtl.Location = New System.Drawing.Point(8, i & 8)
HealthCtl.Show()
Next
but i dont think its right Can someone help me
thanks in advance
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Dec 8th, 2004, 09:00 AM
#2
Hyperactive Member
Re: dynamicly add my custom control
I know you can just create a new instance of your control specifically like this
For i As Integer = 1 To 5
dim HealthCtl as New HB_Server.Health
HealthCtl.Name = "HealthCtl" & i
HealthCtl.Location = New System.Drawing.Point(8, i & 8)
HealthCtl.Show()
Next
instead of
Dim HealthCtl As Control
For i As Integer = 1 To 5
HealthCtl = New HB_Server.Health
HealthCtl.Name = "HealthCtl" & i
HealthCtl.Location = New System.Drawing.Point(8, i & 8)
HealthCtl.Show()
Next
That is how i have used dynamic controls before. hope that helps a little
Edit: I don't know how well that HealthCtl.Location line will work. "i & 8" I assume would "add" i and 8 so on 1 it would be 9... All your controls (if taller than 1 pixel) will overlap. in which case you can use multiplication.
HealthCtl.Location = New Point(8, (i * HealthCtl.Height) + 8)
which if i am thinkin correctly will move the control down 8 pixels under the one before it. It might take a little playing with though I get confused when it comes to logic since I lack quite a bit of that
Last edited by Tool; Dec 8th, 2004 at 09:05 AM.
-
Dec 8th, 2004, 09:44 AM
#3
Re: dynamicly add my custom control
Once you have dynamically created the control, you have to add it to the controls collection of the container (form, pane, pic box, etc) in order for it to work.
Tg
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
|