Showdialog is the call method of the mode form in VB. NET.
If you use the showdialog () method in VB. NET to call a sub-form, you will find that the nature of the mode form in VB. NET is somewhat different from that in VB6.
The position of the form is remembered. The position of each open form is the same as that of the last closed form. If you perform a cyclic value assignment in the subform, you will find that if you do not clear the array before the assignment, the array will be accumulated continuously.
The reason for these problems is that in VB. NET, the form closed by showdialog is actually hidden but not destroyed. No dispose is executed.
To completely destroy the form, you must add the dispose () method to the close or close button of the form. However, this will cause another problem. When the mode form is destroyed, the main form will be repainted. We can see that the main form is flashing, Which is unfriendly to some customers.
The directly close form is not completely destroyed. If you force dispose (), the main form will be refreshed. Is there really no perfect solution?
In fact, there are some methods and they are very simple. Or close () method, but the location is slightly different.
Example:
Main form mainfrm, subform subfrm
1 Private Sub Button#click ( Byval Sender As System. object, Byval E As System. eventargs) Handles Button1.click
2
3 Subfrm. showdialog ()
4 Subfrm. Close ()
5 End sub
(ProgramWrite it in 2010. For other vs versions, you can try to see if the same result will be obtained)
The close () in the fourth row achieves the goal of completely destroying the form. The solution is simple. You can try it yourself!