Real Software Forums

How to add a control dynamically
Page 1 of 1

Author:  Bimal [ Mon Feb 13, 2012 9:39 am ]
Post subject:  How to add a control dynamically

Hi All,

I have a windows application and that application has a button control(Button name is "Add Image").So When i click on that button i want a create file uploader control on that application.How can i do that one.Please tell me.

Bimal .

Author:  arthofer [ Mon Feb 20, 2012 5:53 am ]
Post subject:  Re: How to add a control dynamically

The only way to do this is to clone a existing control.

Add your FileUploader Control to the window, set its index to 0 and its visibility to false.

In the click handler of the button, you create a new instance of that Control and start the upload...

Here you go:
The FileUpload control in your window is called flUpload

dim upload as new flUpload

The new upload control is a copy of the flUpload control.
You may now set it's position/visibility as you want.

But remember that you cant delete those controls.
So you should try to re-use controls if they've done all their events.

(e.g. if the user starts another upload, check if you have idle FileUpload controls and use them to start the upload)

But do you really need the FileUploader (which is one of you own classes) as control?
Because if you have a FileUploader class, you can work directly in code without having the need to create controls.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group