Simcoder Posted July 19, 2005 Posted July 19, 2005 Im having an issue with child forms. Normally, when I want a specific form to stay focused, I use the ShowDialog method. But it won't let me use ShowDialog on childforms so I have to use the Show method instead. The problem is that the show method doesn't ensure that the child form stays focused. Is there a quick fix for this? Thanks in advance. -=Simcoder=- Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Machaira Posted July 19, 2005 Posted July 19, 2005 You want the focus to stay on the form when? What's happening to cause it to lose focus? Quote Here's what I'm up to.
Simcoder Posted July 19, 2005 Author Posted July 19, 2005 Could be a number of reasons. The user trys to click something on another child form that is already up or even the Parent form. Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Joe Mamma Posted July 19, 2005 Posted July 19, 2005 Could be a number of reasons. The user trys to click something on another child form that is already up or even the Parent form. so you want a child form to remain open preventing any other forms from opening until it is closed??? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted July 19, 2005 Posted July 19, 2005 fool around with this in the child form. . . [CS]protected override void OnValidating(CancelEventArgs e) { e.Cancel = this.DialogResult != DialogResult.OK; base.OnValidating(e); } protected override void OnClosing(CancelEventArgs e) { this.DialogResult = DialogResult.OK; base.OnClosing (e); } [/CS] Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Simcoder Posted July 20, 2005 Author Posted July 20, 2005 Sort of. You are right in saying that I don't want any other forms opening up once a particular child form is opened. But I also don't want the user to give any other previous forms that are already open focus either. Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Joe Mamma Posted July 20, 2005 Posted July 20, 2005 play around with the code I posted. . . Attach a delegate to disable your method that opens new forms. . . detach the delegate when the form closes. I am sure some vb'er out there can hack it together. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Machaira Posted July 20, 2005 Posted July 20, 2005 Sort of. You are right in saying that I don't want any other forms opening up once a particular child form is opened. But I also don't want the user to give any other previous forms that are already open focus either. Sounds like something that will seriously piss off users. An MDI app isn't supposed to work that way. If you want a form to be the only one that can have focus until it's closed it should be modal. Quote Here's what I'm up to.
joe_pool_is Posted September 25, 2008 Posted September 25, 2008 Sounds like the form you are showing should *not* be an MDI Child. Just call it like you would a regular form, the use ShowDialog() like you always would. Again, do not set the MdiParent on this particular form, because it sounds like you are not wanting this to be an MDI Child form. I realize this is coming years after you posted the question, but I just happened across it and understood what you were asking. It looks like others might have missed it. Quote Avoid Sears Home Improvement
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.