Click to See Complete Forum and Search --> : dynamically creating a dialog
hannes c
July 13th, 2001, 02:22 AM
Is it possibel to create a dialog at runtime.
More precise, can I create an control, like a
button, listbox, etc. , and place it on a
form at runtime?
thank´s hannes
cmarits@softengineer.de
Clearcode
July 13th, 2001, 03:28 AM
Prior to VB.Net you can only create a control by loading an instance of an existing control array.
For example, suppose you want a form with 20 buttons on it - you create a form with 1 button on it and set it's Index property to zero.
Then to load the others dynamically:
private Sub Form_Load()
Dim lIndex as Long
for lIndex = 1 to 10
Load Command1
command1(lindex).Caption = "Button " & lindex
command1(lIndex).Left = (Comman1(lIndex-1).Left + Command1(lIndex).width)
Command1(lIndex).Visible = true
next lIndex
End Sub
In VB.Net you can just create new controls willy-nilly at run time....(If you can keep the IDE running long enough so to do)
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
John G Duffy
July 13th, 2001, 09:43 AM
There is a way to create a single control at run time. Unfortunately, you can't ceate control arrays using this method with VB6.0 and earlier.
There are simulated control array creation methods available. There is an example of Collection of class Objects posted on this forum By Cesare Cimperiali that performs this magic
http://63.236.73.79/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=53144&Search=true&Forum=vb&Words=collection%20of%20class%20objects&Match=Whole&Topic=&Searchpage=5&Limit=25
John G
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.