Dynamically Create Control

A

Abhishek

Hi,
how can I create controls dynamically in vb.net 2005?

I am building a simple download list (like the downloader u see in firefox)
for which I create a base downloader control. now I want to dynamically
create and add that download control to a panel. I have turned on scrollbars
in panel so it will appear like a download list.


thanks,
abhishek
 
R

rowe_newsgroups

Hi,
how can I create controls dynamically in vb.net 2005?

I am building a simple download list (like the downloader u see in firefox)
for which I create a base downloader control. now I want to dynamically
create and add that download control to a panel. I have turned on scrollbars
in panel so it will appear like a download list.

thanks,
abhishek

Something like the following (typed in the message):

/////////////
Dim listBox as new ListBox()

'// Set all your properties here

downloadPanel.Controls.Add(listBox)
////////////

One way to "cheat" is to layout the control on a form and then open up
the form's designer.vb file, in there you should see all the different
property settings for the control.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
L

Lloyd Sheen

Abhishek said:
Hi,
how can I create controls dynamically in vb.net 2005?

I am building a simple download list (like the downloader u see in
firefox) for which I create a base downloader control. now I want to
dynamically create and add that download control to a panel. I have turned
on scrollbars in panel so it will appear like a download list.


thanks,
abhishek


Something like this:

Dim theControlToAdd as New TheTypeOfControl ' (like Downloader)
' init all properties that you want to use

' now add the control to the Panel
' thePanel.Controls.Add(theControlToAdd)

' you will also have to set the top,left and visible / enabled properties to
ensure that the control is
' in the correct location and shows in the correct way

' Now you will have to add any event handlers you need using AddHandler


Hope this helps
LS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top