469,623 Members | 1,543 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

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

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?

Apr 13 '07 #1
6 1602
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
"Savante" wrote:
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?

Apr 13 '07 #2
On Apr 13, 1:20 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
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

"Savante" wrote:
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?- Hide quoted text -

- 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

Apr 14 '07 #3
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
"Savante" wrote:
>
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

Apr 14 '07 #4
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

Apr 15 '07 #5
On Apr 14, 4:34 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
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

"Savante" wrote:
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- Hide quoted text -

- 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". . . . .?

Apr 15 '07 #6
On Apr 15, 2:00 pm, "Savante" <grant.thom...@savante.co.ukwrote:
On Apr 14, 4:34 pm, Kerry Moorman

<KerryMoor...@discussions.microsoft.comwrote:
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
"Savante" wrote:
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- Hide quoted text -
- 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". . . . .?- Hide quoted text -

- Show quoted text -
awesome!! thanks!

Apr 16 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by fchef | last post: by
2 posts views Thread by Helen Trim | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.