just starting a multiple form project
Okay a question which has been asked a million time before, but what is the correct way to access items ect between forms previously I've done this?
VB Code:
Public Class frmcall
Inherits System.Windows.Forms.Form
Dim form1 As Form1
Private Sub frmcall_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
form1 = DirectCast(Me.Owner, Form1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(form1.BindingContext(form1.ds, "employees.SMS").Current())
MsgBox(Form1.cbocompany.Text)
End Sub
End Class
Which allows me to access all the components of Form1, just really want to check this is the correct way of doing it, as may as well get things right from the start.
Re: just starting a multiple form project
A pretty easy way is just to add a Main Module. In the Main Module declare:
VB Code:
Public MainForm As FormMain
Then in the load event of the main form:
Now MainForm will be an accessible reference in all of your forms. Any Public property, event, method will be exposed.
--Christian
Re: just starting a multiple form project
You should NOT be using the Owner property unless you specifically want to create an owned form. If you don't know what an owned form is then it's safe to say that you don't want that functionality. I suggest you read the tutorial on the first line of my signature.