sethindeed Posted February 12, 2003 Posted February 12, 2003 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 ! Quote What I don't know keeps me excited...
*Experts* Volte Posted February 12, 2003 *Experts* Posted February 12, 2003 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). Quote
sethindeed Posted February 12, 2003 Author Posted February 12, 2003 Yes. I already did it. My question was related to bring an already opened form up front. Sorry if I wasn't clear enough Quote What I don't know keeps me excited...
sethindeed Posted February 12, 2003 Author Posted February 12, 2003 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 :( Quote What I don't know keeps me excited...
*Experts* Nerseus Posted February 12, 2003 *Experts* Posted February 12, 2003 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 Quote "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
sethindeed Posted February 13, 2003 Author Posted February 13, 2003 yep it is ;) Quote What I don't know keeps me excited...
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.