473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Form position

Hi

I have a panel to which I have added several forms as follows;

form1 = New frmone
form1.TopLevel = False
Me.MyPanel.Controls.Add(form1)
form1.BringToFront()

form2 = New frmtwo
form2.TopLevel = False
Me.MyPanel.Controls.Add(form2)
form2.BringToFront()

Is there a way to know which form is currently at the top?

Thanks

Regards

Nov 20 '05 #1
7 1340
* "John" <jo**@nospam.infovis.co.uk> scripsit:
I have a panel to which I have added several forms as follows;

form1 = New frmone
form1.TopLevel = False
Me.MyPanel.Controls.Add(form1)
form1.BringToFront()

form2 = New frmtwo
form2.TopLevel = False
Me.MyPanel.Controls.Add(form2)
form2.BringToFront()

Is there a way to know which form is currently at the top?


Add a variable to the container form and set it to the active form if
one of the form gets, for example, clicked.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
What should be the type of the variable?

Thanks

Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ej**************@TK2MSFTNGP10.phx.gbl...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
I have a panel to which I have added several forms as follows;

form1 = New frmone
form1.TopLevel = False
Me.MyPanel.Controls.Add(form1)
form1.BringToFront()

form2 = New frmtwo
form2.TopLevel = False
Me.MyPanel.Controls.Add(form2)
form2.BringToFront()

Is there a way to know which form is currently at the top?


Add a variable to the container form and set it to the active form if
one of the form gets, for example, clicked.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
* "John" <jo**@nospam.infovis.co.uk> scripsit:
What should be the type of the variable?


'Form'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
OK, I have dim f as form and f = form1 or f = form2 as the case maybe. Now
how can I call a procedure within either form1 or form2 using f as
reference? f.mysub() does not work.

Thanks

Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
What should be the type of the variable?


'Form'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5
* "John" <jo**@nospam.infovis.co.uk> scripsit:
OK, I have dim f as form and f = form1 or f = form2 as the case maybe. Now
how can I call a procedure within either form1 or form2 using f as
reference? f.mysub() does not work.


\\\
If TypeOf f Is Form1 Then
DirectCast(f, Form1).MySub()
ElseIf ... Then
...
End If
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Thanks. Can I not have; DirectCast(f, TypeOf f).MySub() just to save on
coding?

Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ug*************@TK2MSFTNGP10.phx.gbl...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
OK, I have dim f as form and f = form1 or f = form2 as the case maybe. Now how can I call a procedure within either form1 or form2 using f as
reference? f.mysub() does not work.


\\\
If TypeOf f Is Form1 Then
DirectCast(f, Form1).MySub()
ElseIf ... Then
...
End If
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #7
* "John" <jo**@nospam.infovis.co.uk> scripsit:
Thanks. Can I not have; DirectCast(f, TypeOf f).MySub() just to save on
coding?


No. You can use late binding (you will have to disable 'Option
Strict'), but that's not "recommended". Or you can derive all child
form types from a common base form which defines the method or let them
implement an interface. Then you can declare the variable in the type
of that class or interface and won't need to cast.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
Hi all Is there a way in which I can get the Form's position on the screen in pixels? I am having to position another form in relation to an MDI Child form, so I cannot use the Location...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: dale zhang | last post by:
Hi, I build a web form with a 4-cell table on the top (flawlayout), followed by some labels and textboxes (gridlayout). The web form is displayed well in dell m60 laptop with all resolution...
0
by: Steve | last post by:
Hi all Is there a way in which I can get the Form's position on the screen in pixels? I am having to position another form in relation to an MDI Child form, so I cannot use the Location...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
I placed a button on a form menustrip for the purpose of causing the horizontal scrollbar of my form to appear so that I can access controls outside of the form's current view (the controls are...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.