473,406 Members | 2,345 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,406 software developers and data experts.

How to get in front MDI child form?

Hello!

I have a main form as MDIContainer in VB.NET 2002 App. Form has menu
which call several forms. I call forms that way:
--
Dim f As New frmNameX()
LoadForm(f)
--

Procedure LoadForm check if form is already loaded.

Private Sub LoadForm(ByVal frmName As Form)
If Not IsLoaded(frmName) Then
MyForms.Add(frmName) 'Add form to collection list
frmName.MdiParent = Me
frmName.Show() 'Display form on screen
Else
'Bring already open form in focus before other forms
'???? How
End If
End Sub

IsLoaded is function which return True if is loaded and False if it
isn't.

I have more then 20 forms so has to be checked all through one
procedure without defining each forms as separate variable and then
reference on that variable.

I tryed all combinations I know with Activate, Focus, TopLevel, TopMost
etc. without success.
I also have in menu "Window" (set as MDIList=True) where I select
already open form and that work fine. I would like to have the same way
if user would select in my menu same form again.

I think I missed one important step, but don't know which one. Can
anybody help me with that problem?

Regards,
Billy

Nov 21 '05 #1
2 10444
Hi Billy

I don't think you need the separate collection - the MdiChildren of the
parent MDI form should do the trick. try this:

Private Sub LoadForm(ByVal f As Form)
For Each currentForm As Form In Me.MdiChildren
If f.GetType Is currentForm.GetType Then
currentForm.Activate()
Return
End If
Next
f.MdiParent = Me
f.Show()
End Sub

That works for me...

HTH

Nigel Armstrong

"Billy" wrote:
Hello!

I have a main form as MDIContainer in VB.NET 2002 App. Form has menu
which call several forms. I call forms that way:
--
Dim f As New frmNameX()
LoadForm(f)
--

Procedure LoadForm check if form is already loaded.

Private Sub LoadForm(ByVal frmName As Form)
If Not IsLoaded(frmName) Then
MyForms.Add(frmName) 'Add form to collection list
frmName.MdiParent = Me
frmName.Show() 'Display form on screen
Else
'Bring already open form in focus before other forms
'???? How
End If
End Sub

IsLoaded is function which return True if is loaded and False if it
isn't.

I have more then 20 forms so has to be checked all through one
procedure without defining each forms as separate variable and then
reference on that variable.

I tryed all combinations I know with Activate, Focus, TopLevel, TopMost
etc. without success.
I also have in menu "Window" (set as MDIList=True) where I select
already open form and that work fine. I would like to have the same way
if user would select in my menu same form again.

I think I missed one important step, but don't know which one. Can
anybody help me with that problem?

Regards,
Billy

Nov 21 '05 #2
Thank you Nigel!

It's working exactly what I tryed to achieve. Could be some similar
loop also possible for non MDI forms?

For example in my previous code I could comment out line
"frmName.MdiParent = Me" and forms open outside the main window but
only once (no duplicates). But I couldn't activate on any way already
opened form nor in MDI option nor in non MDI (outside the main
window).

Regards,
Billy
Nov 21 '05 #3

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

Similar topics

3
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
2
by: Dean L. Howen | last post by:
Dear friends, I set a form into MDI form with a background image(or some controls), it away in front of the child form which I call at runtime. I get know this doesn't happen at Visual C++ 6.0,...
2
by: Paul | last post by:
Hi this is related to a previous post, hopefully just a bit clearer description o the problem. I have a parent form that opens a new form (child form) while still leaving the parent form open....
1
by: al | last post by:
Greegins, I have child form included in an MDI form. Things work fine until I Close the child form. The prolem is when I try to open that same child form form menu, app crashes saying it can't...
2
by: QT | last post by:
Dear Sirs, I made a MDI Parent form and two MDI child form. I can open MDI child form from MDI parent form with; Dim UserChangePassword_Form As New UserChangePassword 'Set the Parent Form of...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
4
by: jxiang | last post by:
I created a child form that is much bigger than the MDI form in VB.Net. I am trying to capture the whole child form and save as an image or sent to printer. I tried to use BitBlt to capture the...
14
by: Simon Abolnar | last post by:
I would like to know how to open child form from dialog form. Thanks for help! Simon
4
by: Teka Cherenet | last post by:
I am trying to develop a small window application in C# as a front end and SQL server as a back end, but I couldn't make visibility false on the menu of MDI form from a child form. for example I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.