Solved

How can I close the opened form programmatically?

Posted on 2006-11-21
5
269 Views
Last Modified: 2010-04-23
How can I close the opened form programmatically?

Here is what i do

Public class Form1

Dim frm as form2


Private sub ShowForm()

for ctr as integer = 0 to 5

frm = new form2

frm.text = "opened " & ctr

frm.show

next

End Sub



end class




Now, how can I close the form that has the text (caption) = "opened 3" when I click the button on form1?
0
Comment
Question by:JackOfPH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Solar_Flare earned 500 total points
ID: 17992584
you want to keep references to the forms that you create, say put them in an arraylist



Public class Form1


dim ChildForms as arraylist


Private sub ShowForm()

childforms = new arraylist
for ctr as integer = 0 to 5

dim frm as new form2
childforms.add(frm)
frm.text = "opened " & ctr

frm.show

next

End Sub

end class

now you can look through childforms and find the form that you want.
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17992849
How?

Sorry, I am new to vb.net... :)
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17992860
>>now you can look through childforms and find the form that you want.

How can I do this? Can you rpovide me with some sample code?
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17992928
Got it....
Thanks....

Dim temp As Object
        For ctr As Integer = 0 To ChildForms.Count - 1

            temp = ChildForms.Item(ctr)
            If temp.text = "opened 3" Then
                temp.close()
            End If
        Next
0
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 17997999
yep that will do it,

you can also use a for each loop

 For each f as Form2 in childforms
   if f.text = "opened 3" then f.close()
 Next
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question