Is it possible to allow a user to add textboxs during runtime and then be able to drag them where they want, such as creating a custom form?
thanks
Scott
You can move controls (this is just one way, there are MUCH ways to do it ) by using this code:
[tt]
Dim iLeft As Integer, iTop As Integer
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Left = X - iLeft
Source.Top = Y - iTop
End Sub
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
iLeft = X
iTop = Y
Text1.Drag
End Sub [/tt]
And you can create textboxes at runtime by using this code:
1) If you have a control array of a textbox, suppose you have made a control array of Text1, which contains 1 textbox, you can add a nth one by using [tt]Load Text1(n)[/tt].
To edit this one, simply edit the control Text1(n)
2) You can really create it by using this code:
[tt]
Dim ATextbox as TextBox
Set ATextbox = Form1.Controls.Add("VB.TextBox", "key" 'if you wish you can give a third parameter, which specifies to link to a certain container
[/tt]
To edit this one, edit ATextbox (most likely you will build an array here too, if you don't know how much textboxes you will build)
Keep in mind that the textboxes have their visibility set to false, so if you use this code and you don't see anything, thats correct
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.