Jose...that was a brilliant Idea. What i dont know is how i can be able to close and dispose all forms when my page number is 0. I only want to dispose them off when the user shows that he doesnt want to go on with that data he wrote on the pages(i.e removing page1 from the panel or pressing cancel).
So if the user goes back upto page1 and he presses Back again, let all the forms be disposed, but if he presses next,he will get his information previously written and the forms will not be disposed off.
My code is below.
VB Code:
Private cls_FP As New cls_FormProperties Private Sub btnBack_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click If cls_FP.pageNumber = 1 Then cls_FP.pageNumber -= 1 Me.SplitContainer1.Panel2.Controls.Remove(cls_FP._frm1) Me.btnBack.Enabled = False ElseIf cls_FP.pageNumber = 2 Then cls_FP.pageNumber -= 1 showform(cls_FP._frm1) ElseIf cls_FP.pageNumber = 3 Then cls_FP.pageNumber -= 1 showform(cls_FP._frm2) ElseIf cls_FP.pageNumber = 4 Then cls_FP.pageNumber -= 1 showform(cls_FP._frm3) Me.btnFinish.Enabled = False End If End Sub Private Sub btnNext_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click If cls_FP.pageNumber = 0 Then cls_FP.pageNumber += 1 Me.btnBack.Enabled = True showform(cls_FP._frm1) ElseIf cls_FP.pageNumber = 1 Then cls_FP.pageNumber += 1 showform(cls_FP._frm2) ElseIf cls_FP.pageNumber = 2 Then cls_FP.pageNumber += 1 showform(cls_FP._frm3) ElseIf cls_FP.pageNumber = 3 Then cls_FP.pageNumber += 1 showform(cls_FP._frm4) Me.btnFinish.Enabled = True End If End Sub Private Sub showform(ByRef frm As Form) Dim ctrl As Control For Each ctrl In Me.SplitContainer1.Panel2.Controls If TypeOf ctrl Is Form Then Me.SplitContainer1.Panel2.Controls.Remove(ctrl) 'If cls_FP.pageNumber = 0 Then 'DirectCast(ctrl, Form).Close() 'DirectCast(ctrl, Form).Dispose() 'End If End If Next frm.TopLevel = False Me.SplitContainer1.Panel2.Controls.Add(frm) frm.Dock = DockStyle.Fill frm.Show() End Sub




Reply With Quote