Form load data before showdialog
I have problems with a form and load event.
My form manage items that can be added, deleted or modified. In load code, I initialize all vars to cero. This is OK to be ready to add items.
My problem is with modify and delete. To carry this, I must load vars from a source. So, in my foreing code I have this:
Code:
Dim frm As newMyForm
frm = New newMyForm()
Dim resultado As Boolean = frm.duplicar("0003")
If (resultado = False) Then
MsgBox("Could not open 0003")
frm.Close()
Return
End If
frm.ShowDialog()
Me.Close()
frm.duplicar load data based on 0003 as index.
My problem is that when showdialog is called, all data which were loaded from duplicar funct is put again to cero. How can I avoid this and load correct data into the form.
Thanks
Re: Form load data before showdialog
Have you stepped through the code to make sure that the data is indeed being cleared? Once you load data, it doesn't just disappear.
Re: Form load data before showdialog
You say that this:
Quote:
In load code, I initialize all vars to cero.
Does that mean in the Load event handler of the form? The Load event handler is not executed until you LOAD the form, not when you CREATE the form. That means the Load event handler is executed AFTER you call ShowDialog.
Why do you need any code to set anything to zero anyway? It's a brand new form so everything is zero by default and will only have some other value if you set it so.