Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vb.net dynamically add, name, place and resize text boxes to a windows form

Posted on 2009-04-21
5
Medium Priority
?
180 Views
Last Modified: 2013-11-26
Hi Experts - I am trying to create a form that will add texboxes to a form.  Just to figure it out, I have created a simple form with one button and one text box.  User enters a number in the text box and it shoud create that number of textboxes. I don't know if I am going about this the wrong way, but here is what I have so far - Also is there a way to dictate the size and  position  -(by the way, I am a newbie)
Thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim I As Integer
        MsgBox(txtNumber.Text)
        For I = 1 To txtNumber.Text
            Dim myTextBox = New TextBox
            myTextBox.Name = "txtDynamic" & I
            myTextBox.Text = "Control Number:" & I
            Me.Controls.Add(myTextBox)
        Next
 
 
    End Sub

Open in new window

0
Comment
Question by:NCSA SCADA
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 24199079
myTextBox.Size = new size(x,y)
myTextBox.Location.X =
myTextBox.Location.Y =
0
 

Author Comment

by:NCSA SCADA
ID: 24199184
Thanks for the quick response -
I must be missing somthing - I tried this
            myTextBox.Size = New Size(10, 10)
            myTextBox.Location.X = "485"
            myTextBox.Location.Y = "339"
I get this error - "Expression is a value and therefore cannot be the target of an assignment
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24199429
You can use also SetBound()
Ex.

        For I As Byte = 1 To 5
            Dim myTextBox As New TextBox
            myTextBox.Name = "txtDynamic" & I
            myTextBox.Text = "Control Number:" & I
            myTextBox.SetBounds(10, 20 * I, 120, 20)
            Me.Controls.Add(myTextBox)
        Next

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24199433
Here you have some extra information
http://msdn.microsoft.com/en-us/library/z0tayb1b.aspx 
0
 

Author Closing Comment

by:NCSA SCADA
ID: 31573019
That worked perfect - thanks for the additional info as well - cleared it right up
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question