gomindi Posted January 9, 2003 Posted January 9, 2003 Here is the code that I am using (Thanks to Divil) to create a textbox on the fly: Dim a As New TextBox() a.Text = items(0) a.Location = New Point(20, 75) Controls.Add(a) Now I would like to know how to create a variable that will calculate my next location of my text box. Any ideas? Thanks! Mindi Quote
*Experts* Nerseus Posted January 9, 2003 *Experts* Posted January 9, 2003 You should also specify the size, with: a.Size = New Size(64, 24) '64x24 pixels The new location depends on what you want. Normally you'll use an offset from the previous textbox. You might have something like: Dim lastY As Int32 = 0 'looping here Dim a As New TextBox() a.Text = items(0) a.Size = New Size(64, 24) a.Location = New Point(20, lastY) Controls.Add(a) '4 represents 4 pixels between each textbox lastY = lastY + a.Height + 4 'or use the following: 'lastY = a.Top + a.Height + 4 'loop til here How you're doing your looping and where you're creating your textbox will determine how/where you store that last Y value. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.