SetFocus

sethindeed

Centurion
Joined
Dec 31, 1969
Messages
118
Location
Montreal Canada
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 !
 
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).
 
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:
C#:
foreach(Form f in this.MdiChildren)
{
    // Use f.Show() or whatever you need...
}

-ner
 
Back
Top