Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic control creation

Status
Not open for further replies.

raviman

Programmer
Sep 28, 1999
9
IN
Can somebody please tell me how to add controls such as textboxes on the form dynamically( i.e. during run time through the code )<br>
Thanks in advance<br>
Raviman <p>Ravi Kochher<br><a href=mailto:rkochher@velos.ssind.com>rkochher@velos.ssind.com</a><br><a href= > </a><br>
 
It may be easier to create the controls (or control array), set the Visible property to False at design time and then use the code to set Visible to True and move the controls to the correct position on the form when required at run time.
 
Create a single textbox (or whatever) - make it a control array with just the one element (set the index to 1) - call it tb.<br>
<br>
then try this<br>
<br>
dim i<br>
for i = 2 to 10<br>
load tb(i) ' tb(1) is your textbox already on screen<br>
tb(i).left = tb(i-1).left + 50<br>
tb(i).top = tb(i-1).top + tb(i-1).height + 50<br>
next i<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
Thanks Mike. <br>
I just have to set the visibility true for the text box I loaded by your code.<br>
<p>Ravi Kochher<br><a href=mailto:rkochher@velos.ssind.com>rkochher@velos.ssind.com</a><br><a href= > </a><br>
 
Ahhh &lt;embarrassment&gt; Good strong technical point there Ravi - unless the tb is visible - you can't see it. Sort of an obvious point really, but I managed to miss it.<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
There are a number of sites around with source code that shows various ways to do that. search altavista for +&quot;visual basic&quot; +&quot;source code&quot; +dynamic. One site was, I think, thescars.com.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top