Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a form with a textbox on top of it.

When i press Enter a new textbox appears below and gets the focus.

I can add 50 textboxes this way

 

The code for textbox number i is :

Dim txt As New TextBox

txt.Location = New Point(100, 200 + 50 * i)

Me.Controls.Add(txt)

AddHandler txt.KeyPress, AddressOf txt_keypress

 

Now when i come to the twentieth textbox of course i'm at the bottom of the form and if i add more textboxes i don't see them.

So i have activated the property AutoScroll.

 

But there is a problem : now the form does scroll and i can see the new textboxes. The first textboxes appear just right, but when the form starts to scroll, they don't appear in their right location anymore (as if the location was modified by the scrolling)

 

What is happening???

please help!!:eek:

Posted

I don't understand you problem.

 

Of course the (peceived) location changes, when the panel starts to scroll.

 

How is the location changing?

.nerd
Posted

No, i mean with the code txt.Location = New Point(100, 200 + 50 * i)

the textboxes should be regularly positionned (with a distance of 50 between each of them)

But when the scrolling happens, the textboxes are nor regularly disposed anymore : the distance between the twentifirst textbox and the twentieth is not 50 anymore.

Posted

I am just guessing:

- the panel scrolls to put Textbox 20 into view.

What used to be (0,0) is now (0,-45) for example.

 

As I am the guy for dirty tricks, I'd suggest the following:

 

Put a new system.drawing.point in the upper right corner of the panel / form (i.e. 0,0) and name it ptOffset-

 

When positioning a new textbox, add the X/Y Coordinates of ptOffset to the textboxes location.

.nerd
Posted

Thanks for your help, now the textboxes appear jsut regularly...

 

Another problem though has appeares (i think it is bound to the autoscroll property) : when i press Enter, my next textbox appears (thank you!) and the form scrolls down a little bit so that i can see it.

But this new text box is at the very botto of the form and partyl hidden (not very pretty)...!

 

Is there a way that when the textbox is at the very bottom of the form, the form scrolls down a long way so that the textbox now appears at the top or middle of the form?

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...