Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have an MDIForm and some child forms.

I already wrote a routine that prevent a form from opening two times.

What I want to do next is that when the user tries to open an already opened form, I want this form to be in focus.

I used to do it quite easily in VB6 with the SetFocus method but this method is gone in .NET.

Anybody knows how can I do what I want ?

thx !

What I don't know keeps me excited...
  • *Experts*
Posted

You can use a For Each to cycle through all open MDIForms and check

to see if it's an instance of the particular form using (I think) the TypeOf

operator (If TypeOf theForm Is Form2 Then theForm.Focus(), or

something similar).

Posted

Actually, I have some difficulties with the For Each syntax.

 

For each frm in Forms does not work

 

For each frm in System.Windows.Forms does not work neither :(

What I don't know keeps me excited...
  • *Experts*
Posted

There is no more Forms collection in .NET, you'll have to create your own if you want this feature. An MDI form does keep track of it's children. You can use:

foreach(Form f in this.MdiChildren)
{
   // Use f.Show() or whatever you need...
}

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

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