Closing a Form

jtoutou

Active member
Joined
Oct 11, 2008
Messages
26
Programming Experience
Beginner
Hi....I have a form with text boxes ,masked text boxes e.t.c
there is a binding (data) source (MytablebindingSource)..
..when i open the form
the on form_load event i use the following code
VB.NET:
Private Sub My_Form(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
.
..
...
Me.MytableTableAdapter.Fill(Me.MyTableDataSet.MyTable)

Me.MyTableBindingSource.AddNew()
with the addnew i have empty boxes and new row is ready to get new data
When i try to close the form for any reason without filling data inside, the button does not work
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Validate()
                Me.Close()
    End Sub
what is happening
1.because there are required fields in the form?
2.because the button is positioned inside a panel?
3.or because my code is wrong?
pls someone guide me

the only way to close my form (and works) is this

the previous form
opens a form in panel
VB.NET:
'form1
me.panle1.controls.add(form2)
and when i need to close the form2
i need to write also:
VB.NET:
'form2
form1.panel1.controls.remove(me)
me.close()

could somebody tell me why the panel overrides the form???
 
Last edited:
Back
Top