Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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=-

Whatever thy hand findest to do, do it with all thy heart - Jesus
Posted
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.
Whatever thy hand findest to do, do it with all thy heart - Jesus
Posted
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???

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.

Posted

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]

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.

Posted
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.
Whatever thy hand findest to do, do it with all thy heart - Jesus
Posted

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.

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.

Posted
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.

Here's what I'm up to.
  • 3 years later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...