I want to create multiple instances of a form and then refer to individual instances.

S

Savante

I have been writing a datalogging application. It reads in double's
into a database. I want to be able to click on a row in a database
(holds name of variable and also current value of variable) and then
instantiate a new form.

I created a new form form2 and then just on double click on a
button....

dim form as new form2
form.show

this allows me to create individual forms which I feed particular
variables.

now the issue for me is, how do i refer to each instance of form2
(want to be able to create form instances dynamically) individually.
i want to be able to send updated data from the database to each
window instance so that I can display multiple pieces of information
in individual scaleable windows..

is there a way to refer to a single instance of a new form?
 
G

Guest

Savante,

Each time you create a new form you could add it to a collection, such as an
array, arraylist, list, hashtable, dictionary, etc.

Then you could refer to it by using an index or key.

Kerry Moorman
 
S

Savante

Savante,

Each time you create a new form you could add it to a collection, such as an
array, arraylist, list, hashtable, dictionary, etc.

Then you could refer to it by using an index or key.

Kerry Moorman










- Show quoted text -

thanks for the reply.

I had a bash at this last night again - had a module with
dim arrayform(100) as form1 ' (form1 is the copy of the data display
window)
and then when I click a button in frmmain it goes somthing like.

public sub button1.click......
i+=1
arrayform(i)=new form
arrayform(i).show

is this what you mean? It seems to allow me to refer to particular
windows now I think. I was going to adjust the form1_closing such
that it simply hides the window rather than deletes it and then use
the value of i as a key to identify when tooo many form1 instances
were open?

Best Regards,

Grant
 
G

Guest

Grant,

Yes, that is one of the approaches that I was suggesting.

Another option would be to add each form to an arraylist or list. Then you
would not have to manage the size of the collection. Each new form could be
added to the collection without having to keep track of the size of the
collection or the index value, etc.

Kerry Moorman
 
S

Savante

Kerry,

Cheers,

How do I do that? :-(

in module -
dim grantform as arraylist?

and then in the class........

grantform as new form1
grantform.show?

how do I keep track of each instance of each form as it's
instanciated?

Best Regards,

Grant
 
S

Savante

Grant,

Yes, that is one of the approaches that I was suggesting.

Another option would be to add each form to an arraylist or list. Then you
would not have to manage the size of the collection. Each new form could be
added to the collection without having to keep track of the size of the
collection or the index value, etc.

Kerry Moorman










- Show quoted text -

Kerry,

This opens up another can of worms. I've done the following

in module - friend formlist as arraylist

in each instance of opening a new form I've gone

dim instanceform as form
instanceform=new form
formlist.add(instanceform)

and so I'm presuming that this adds each instance of the form
instantiation to arraylist at a unique index position.

I would like to be able to change values in each instance of the form
using database values, but my question is how do I address the (for
example) label1.text parameter of each particular instance of the
form?

formlist(1).label1.text="whatever data I like". . . . .?
 
S

Savante

Kerry,

This opens up another can of worms. I've done the following

in module - friend formlist as arraylist

in each instance of opening a new form I've gone

dim instanceform as form
instanceform=new form
formlist.add(instanceform)

and so I'm presuming that this adds each instance of the form
instantiation to arraylist at a unique index position.

I would like to be able to change values in each instance of the form
using database values, but my question is how do I address the (for
example) label1.text parameter of each particular instance of the
form?

formlist(1).label1.text="whatever data I like". . . . .?- Hide quoted text -

- Show quoted text -

awesome!! thanks!
 

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