MDIMain and Form Containting user control

N

NxDevel

Hello,

I am having a problem with a MDI VB.net application.
The problem is if I have two forms loaded, lets call them Form A and Form B.
Form A is loaded first then Form B. Form B is a blank form that houses a
user control. From the user control When the user clicks on a find button it
launches a Search screen well call this Form C . When I select the correct
Item on Form C it fires off an event to tell the listening form who was
searched for and then closes. Form B captures the event and populates some
fields. This works great! The problem is that Form B gets hidden behind
Form A. Why did Form A come to the forefront when Form B was the form that
called Form C. And When Form C closes I expected Form B to be on top.

It used to work this way when Form B was just a form and not a form housing
a user control. Is there a setting that I have missed. I've tried setting
the parent of the user control to Form B. But that did not work.

Thank you!
 
L

Linda Liu[MSFT]

Hi NxDevel,

I performed a test based on your description but didn't reproduce the
problem on my side.

The following is the walkthrough of my test.
1. Create a WinForm application project. Add a Form named Form2 in the
project.
2. Create a UserControl and add a Button on it. Handle the Button's Click
event as follows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim frm As New Form
frm.Show()
End Sub

3. Build the project and put the UserControl onto the Form2.
4. In the Form1's code file, add the following code snippet:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim frmA As New Form
frmA.MdiParent = Me
frmA.Show()

Dim frmB As New Form2
frmB.MdiParent = Me
frmB.Show()
End Sub

Build and run the application. Two forms are shown in the MDI parent and
the Form2 is on the top. Click the Button on the Form2, and another form is
opened. Close the third form and the Form2 is activated and still on the
top.

If your problem still exists, you'd better send me a simple project that
could just reproduce the problem. To get my actual email address, remove
'online' from my displayed email address.

I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu[MSFT]

Hi NxDevel,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

BTW, you'd better post your WinForm related issues to the
microsoft.public.dotnet.framework.windowsforms newsgroup in the future so
as to get more help from experienced communities as well as support from MS.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top