By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,971 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,971 IT Pros & Developers. It's quick & easy.

Using the form handle

P: n/a
I'm looking for a way to bring an open form to the top. I know that is I
open a form directly with form1.show() and then later, while the form is open
I do another form1.show(), that I will get original form to pop to the top.
But because I want to have multiple instances of form1 open, I open it with

dim frm as new form1
frm.show()

What I need to do now is reference the opened form from another window and
even pop it to the top if I want to. I've seen that I can capture
frm.Handle. If frm.Handle is 1234;

1) Can I
frm.handle(1234).show()
or
2) Can I
frm.handle(1234).textbox1.text = "Hello"

Thanks

Aug 14 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Rich,

No, you can't.

Instead of storing the handle why not store a reference to the instance of the Form1 class that you need to show? Then you can just
call frm.Show(), as you mentioned.

You can search for a particular control by index or name as long as you have a reference to the Form.

--
Dave Sexton

"RichG" <Ri***@discussions.microsoft.comwrote in message news:74**********************************@microsof t.com...
I'm looking for a way to bring an open form to the top. I know that is I
open a form directly with form1.show() and then later, while the form is open
I do another form1.show(), that I will get original form to pop to the top.
But because I want to have multiple instances of form1 open, I open it with

dim frm as new form1
frm.show()

What I need to do now is reference the opened form from another window and
even pop it to the top if I want to. I've seen that I can capture
frm.Handle. If frm.Handle is 1234;

1) Can I
frm.handle(1234).show()
or
2) Can I
frm.handle(1234).textbox1.text = "Hello"

Thanks

Aug 14 '06 #2

P: n/a
Dave
Thanks for the reponse.
I guess a reference is what I thought I could get with the handle. How
would I obtain a reference that I could later address?
Thanks

"Dave Sexton" wrote:
Hi Rich,

No, you can't.

Instead of storing the handle why not store a reference to the instance of the Form1 class that you need to show? Then you can just
call frm.Show(), as you mentioned.

You can search for a particular control by index or name as long as you have a reference to the Form.

--
Dave Sexton

"RichG" <Ri***@discussions.microsoft.comwrote in message news:74**********************************@microsof t.com...
I'm looking for a way to bring an open form to the top. I know that is I
open a form directly with form1.show() and then later, while the form is open
I do another form1.show(), that I will get original form to pop to the top.
But because I want to have multiple instances of form1 open, I open it with

dim frm as new form1
frm.show()

What I need to do now is reference the opened form from another window and
even pop it to the top if I want to. I've seen that I can capture
frm.Handle. If frm.Handle is 1234;

1) Can I
frm.handle(1234).show()
or
2) Can I
frm.handle(1234).textbox1.text = "Hello"

Thanks


Aug 15 '06 #3

P: n/a
Hi RichG,

You wrote in your last post, "I've seen that I can capture frm.Handle".

Wherever in code you were going to assign a global variable to frm.Handle, simply store frm instead. Since you need to store
multiple references, you'll have to store a collection of forms.

If your using the 2.0 framework, you can use the following, for example:

Private List<FormmyForms As New List<Form>() 'how do you code generics in VB?

Private Function CreateForm() As Form
Dim frm As New Form1();
myForms.Add(frm)
Return frm
End Function

If you are using an earlier version of the framework just replace the generic list with an ArrayList, for example.

HTH (please forgive me for my lousy VB)

--
Dave Sexton

"RichG" <Ri***@discussions.microsoft.comwrote in message news:78**********************************@microsof t.com...
Dave
Thanks for the reponse.
I guess a reference is what I thought I could get with the handle. How
would I obtain a reference that I could later address?
Thanks

"Dave Sexton" wrote:
>Hi Rich,

No, you can't.

Instead of storing the handle why not store a reference to the instance of the Form1 class that you need to show? Then you can
just
call frm.Show(), as you mentioned.

You can search for a particular control by index or name as long as you have a reference to the Form.

--
Dave Sexton

"RichG" <Ri***@discussions.microsoft.comwrote in message news:74**********************************@microsof t.com...
I'm looking for a way to bring an open form to the top. I know that is I
open a form directly with form1.show() and then later, while the form is open
I do another form1.show(), that I will get original form to pop to the top.
But because I want to have multiple instances of form1 open, I open it with

dim frm as new form1
frm.show()

What I need to do now is reference the opened form from another window and
even pop it to the top if I want to. I've seen that I can capture
frm.Handle. If frm.Handle is 1234;

1) Can I
frm.handle(1234).show()
or
2) Can I
frm.handle(1234).textbox1.text = "Hello"

Thanks



Aug 15 '06 #4

P: n/a
Dave Sexton wrote:
Hi RichG,

You wrote in your last post, "I've seen that I can capture frm.Handle".

Wherever in code you were going to assign a global variable to frm.Handle, simply store frm instead. Since you need to store
multiple references, you'll have to store a collection of forms.

If your using the 2.0 framework, you can use the following, for example:

Private List<FormmyForms As New List<Form>() 'how do you code generics in VB?
Private myForms As New List(Of Form)

Think in English... code in English :)

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Aug 16 '06 #5

P: n/a
Hi Larry,

Thanks for the answer. Very close to proper English, however, I never would have guessed that the use of an 'Of' operator is
required ;)

--
Dave Sexton

"Larry Lard" <la*******@googlemail.comwrote in message news:4k************@individual.net...
Dave Sexton wrote:
>Hi RichG,

You wrote in your last post, "I've seen that I can capture frm.Handle".

Wherever in code you were going to assign a global variable to frm.Handle, simply store frm instead. Since you need to store
multiple references, you'll have to store a collection of forms.

If your using the 2.0 framework, you can use the following, for example:

Private List<FormmyForms As New List<Form>() 'how do you code generics in VB?

Private myForms As New List(Of Form)

Think in English... code in English :)

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version

Aug 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.