Connecting Tech Pros Worldwide Forums | Help | Site Map

Using the form handle

RichG
Guest
 
Posts: n/a
#1: Aug 14 '06
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


Dave Sexton
Guest
 
Posts: n/a
#2: Aug 15 '06

re: Using the form handle


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" <RichG@discussions.microsoft.comwrote in message news:74C901D7-30DB-4ABE-A765-7DDC754C72AC@microsoft.com...
Quote:
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
>

RichG
Guest
 
Posts: n/a
#3: Aug 15 '06

re: Using the form handle


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:
Quote:
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" <RichG@discussions.microsoft.comwrote in message news:74C901D7-30DB-4ABE-A765-7DDC754C72AC@microsoft.com...
Quote:
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
>
>
>
Dave Sexton
Guest
 
Posts: n/a
#4: Aug 16 '06

re: Using the form handle


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" <RichG@discussions.microsoft.comwrote in message news:78F8A50B-9D30-45B4-B615-7E9D43A69B70@microsoft.com...
Quote:
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:
>
Quote:
>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" <RichG@discussions.microsoft.comwrote in message news:74C901D7-30DB-4ABE-A765-7DDC754C72AC@microsoft.com...
Quote:
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
>
>>
>>
>>

Larry Lard
Guest
 
Posts: n/a
#5: Aug 16 '06

re: Using the form handle


Dave Sexton wrote:
Quote:
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
larrylard@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Dave Sexton
Guest
 
Posts: n/a
#6: Aug 16 '06

re: Using the form handle


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" <larrylard@googlemail.comwrote in message news:4kg73oFc1movU2@individual.net...
Quote:
Dave Sexton wrote:
Quote:
>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
larrylard@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version

Closed Thread