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

MDI childs - can't make active no matter what i try

Hello everyone,

I have a C# winforms application which is designed as a mdi application.
I am having a focus problem with it that I cannot seem to solve.

If I open a mdi child and it is the only child form that is open in the mdi parent then the focus sets to this mdi child without issue and the cursor appears in the text field with the tab index of 0 exactly as it should.

However, if I open up a mdi child form and another mdi child form is already open in the mdi parent, then the mdi chid becomes active (the title bar is bright blue as if it is active) but the cursor stays on the first mdi child window. So if I hit the tab key even though the back window does not have focus, the controls in the back window are being tabbed through rather than the front window with focus.

I thought that it might relate to how I was displaying the mdi child so I have tried all of these options include many variations of sequence
frmPOS.TopMost = true;
frmPOS.Show();
frmPOS.Activate();
frmPOS.Focus();
frmPOS.BringToFront();
frmPOS.Refresh();
frmPOS.Select();
frmPOS.Update();

No matter what I do, the cursor will not appear in the mdi child that i display if at least 1 mdi child is already on the screen.

Any ideas?
Nov 16 '06 #1
1 2977
Well I answered my own question and I hope that this helps someon else out.

I bet this is causing 99% of the mdi child focus problems that everyone is experiencing when you search on google, msdn or here on these boards.

The problem with my mdi child focus issue was being caused by the way i was firing and handling events or by the way .net handles this functionality.

In my application, a modal dialog was being displayed so that users could type in employee numbers before opening a mdi child screen (for security purposes).

This box was firing events of loginSucceeded and loginFailed and the event handlers would then close the modal login screen and show the correct mdi child form.

You would think this would work but when stepping through the code i noticed that irregardless as to whether I closed the modal form or not, .net was still returning focus back to it to finish out the sub procedure after the event fired and this was pulling focus away from my mdi child forms.


So i removed the event functionality and used the DialogResult returned from the modal dialog instead which ensured that this window was closed prior to showing the mdi child and that resolved the issue.

If you are having mdi child focus issues, step through the code with f10 and see if focus is being set somewhere else after your mdichild is displayeyed.

8 )

hope that helps someone.
Nov 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Lin Ma | last post by:
I first post this to win2000.active_directory group and I find out it may be a wrong group. I hope this group can help me. Hello, In ASP page, does any one knows how to get user network...
3
by: -H | last post by:
Hi, I have a "parent" C program that forks off a "child" C program. Both the parent and the child print information to both stdout and stderr. I would like to redirect the parent and childs...
2
by: Sergio del Amo Caballero | last post by:
Hi, I have a structer like this: <div class="node"> <a><img /></a> <div class="child"> <a><img /></a> </div> <div class="child"> <a><img /></a>
4
by: Stephen Poley | last post by:
The issue of the focus pseudo-class came up a few weeks ago, and I finally got around to trying it out (better late than never ...) The recommended order given for the pseudo-classes is link,...
13
by: Krzysztof Bartosiewicz | last post by:
Hi! I have a problem with an access database. The database which I designed and made using MS access works perfectly OK on my computer however it is not working at all on computers for which it...
2
by: Bob Hollness | last post by:
Hi group. Merry Xmas one and all!!!! I hope Santa brings you all something good. For me, I would be happy with some nice code! If I check a node in a treeview, how do I check all childs of...
0
by: B111Gates | last post by:
OK I know this is a complex question so I will break it up. I know that SSPI is the prefered method of authentication, however if I use the sample provide by MS I cannot authenticate across...
1
by: Stampede | last post by:
Hello, I created a Windows Application Project and tried to create a MDI-based application. So I created a new MDI-parent with the creation wizzard. Then I created a default form and tried to make...
4
osward
by: osward | last post by:
I had made a table colum sortable and paging the table, following are the code // Display Event List echo "<center>"._EVENTLIST."</center><br>"; $now = Date(Y-m-d); // sort table...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.