A button on my Form1 opens Form2. Simple as that.
In VB6 I was using....
[VB]
Form2.Show(1)
[/VB]
to show the form modally and the cancel button on Form2 would have the code...
[VB]
Unload Me
[/VB]
This doing the same thing as clicking on the close icon.
Form2 would appear, its Load event having been executed and then it would close when the appropriate button was clicked. If I wanted to open it again then it would do so exactly the same.
Now in VB.NET I cant use Form2.Show(1) apparently I have to use...
[VB]
Form2.ShowDialog()
[/VB]
...if I want the form to open modally. So here we get to the first problem. If I use ShowDialog instead of Show then the Load event of the form doesnt execute. So I use Form2.Show() and put up with the fact the form isnt modal.
The second problem is that Unload Me no longer exists and according to another thread here the equivalent is...
[VB]
Me.Close()
[/VB]
This however causes problems when I click the button to execute the code Form2.Show() code again. It gives me the error Cannot access a disposed object named "Form2". I can make the Cancel button Me.Hide() instead but if the user clicks the close icon then this error is gonna occur.
Oh my god my heads about to explode.
All Im after is for Form2 to open modally AND execute its Load event AND NOT get that damned error when I try an open it again later. (Something I could do in VB6 in 2 lines containing 4 words, 1 integer, 1 pair of brackets and a full stop!)
And if at all possible could someone tell me why Microsoft would take something as easy to use as VB6 and turn it into the complete and utter pig that is VB.NET?
Grrrr....
In VB6 I was using....
[VB]
Form2.Show(1)
[/VB]
to show the form modally and the cancel button on Form2 would have the code...
[VB]
Unload Me
[/VB]
This doing the same thing as clicking on the close icon.
Form2 would appear, its Load event having been executed and then it would close when the appropriate button was clicked. If I wanted to open it again then it would do so exactly the same.
Now in VB.NET I cant use Form2.Show(1) apparently I have to use...
[VB]
Form2.ShowDialog()
[/VB]
...if I want the form to open modally. So here we get to the first problem. If I use ShowDialog instead of Show then the Load event of the form doesnt execute. So I use Form2.Show() and put up with the fact the form isnt modal.
The second problem is that Unload Me no longer exists and according to another thread here the equivalent is...
[VB]
Me.Close()
[/VB]
This however causes problems when I click the button to execute the code Form2.Show() code again. It gives me the error Cannot access a disposed object named "Form2". I can make the Cancel button Me.Hide() instead but if the user clicks the close icon then this error is gonna occur.
Oh my god my heads about to explode.
All Im after is for Form2 to open modally AND execute its Load event AND NOT get that damned error when I try an open it again later. (Something I could do in VB6 in 2 lines containing 4 words, 1 integer, 1 pair of brackets and a full stop!)
And if at all possible could someone tell me why Microsoft would take something as easy to use as VB6 and turn it into the complete and utter pig that is VB.NET?
Grrrr....