|
-
Jul 3rd, 2002, 06:08 AM
#1
Thread Starter
Junior Member
creating runtime controls
I am trying to create a form that allows the user to enter the number of text box controls they want to generate and then have the form generate these controls triggered via the click event of the submit button.
It appears I could do this as 2 forms and create the 2nd form dynamically but I thought I could use the same form and simply add the new controls to the Controls() collection and then refresh the form rather than closing the old form and opening a new one.
Does anyone have any thoughts or ideas?
-
Jul 3rd, 2002, 06:25 AM
#2
There should be no problems adding the controls to the existing form.
Show us the code you use, maybe we can point out some mistakes.
-
Jul 3rd, 2002, 06:31 AM
#3
Thread Starter
Junior Member
found my own answers again
Well, once again I posted something and somehow imemdiately answered my own question. As it turns out, this is quite easy. I just set some controls within the onclick even of a button and I did not need to call a refresh.
Dim myLabel As Label = New Label()
Dim myLabel2 As Label = New Label()
Me.Controls.Add(myLabel)
Me.Controls.Add(myLabel2)
myLabel.Text = "Dynamically added label control."
myLabel.Left = 100
myLabel.Top = 10
myLabel2.Text = "Dynamically added label control."
myLabel2.Left = 100
myLabel2.Top = 35
-
Jul 11th, 2002, 05:47 AM
#4
This may be better:
Dim myLabel As New Label
Dim myLabel2 As New Label
Me.Controls.Add(myLabel)
Me.Controls.Add(myLabel2)
myLabel.Text = "Dynamically added label control."
myLabel.Left = 100
myLabel.Top = 10
myLabel2.Text = "Dynamically added label control."
myLabel2.Left = 100
myLabel2.Top = 35
Wasn't much to it. You were nearly there.
Have fun!
«°°phReAk°°»
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Jul 11th, 2002, 05:49 AM
#5
that works aswell. heh, sorry, i didnt see your second one.
Apologies
«°°phReAk°°»
Visual Studio 6, Visual Studio.NET 2005, MASM
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
|