Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...