C
Chris Strug
Hi there,
Possibly something of a simple question but I was wondering is anyone could
provide a few pointers or links.
Given that I have two forms, a main (frmMain) and a child (frmChild). From
frmMain, I create an instance of frmChild and show() it. The child form
contains a property called "getString" which I want to return the contents
of a textbox from the child form.
I have something that I think works, however it falls over if the user exits
the child form (such as by using the corner cross) instead of clicking
cmdReturnData.
I was just wondering if I am on the right lines - creating properties and so
on for the child form seem pretty intuititive but actually calling them from
the main form trouble free seems to be a pain.
Apologies if this is a little vague - I'm working on my .net having moved
from vb6 so I'm still trying to get used to the way that .net works...
Thanks
Chris.
************************
Public Class FrmMain
Dim frmChild As New frmChild
Private Sub mainFrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub cmdShowChild_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdShowChild.Click
frmChild.ShowDialog()
Me.txtRetrievedData.Text = frmChild.getString
frmChild.Dispose()
End Sub
End Class
****************
Public Class frmChild
Public Property getString()
Get
Return Me.txtChildTextvalue.Text
End Get
Set(ByVal value)
End Set
End Property
Private Sub auxFrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub cmdReturnData_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdReturnData.Click
Me.Hide()
End Sub
End Class
Possibly something of a simple question but I was wondering is anyone could
provide a few pointers or links.
Given that I have two forms, a main (frmMain) and a child (frmChild). From
frmMain, I create an instance of frmChild and show() it. The child form
contains a property called "getString" which I want to return the contents
of a textbox from the child form.
I have something that I think works, however it falls over if the user exits
the child form (such as by using the corner cross) instead of clicking
cmdReturnData.
I was just wondering if I am on the right lines - creating properties and so
on for the child form seem pretty intuititive but actually calling them from
the main form trouble free seems to be a pain.
Apologies if this is a little vague - I'm working on my .net having moved
from vb6 so I'm still trying to get used to the way that .net works...
Thanks
Chris.
************************
Public Class FrmMain
Dim frmChild As New frmChild
Private Sub mainFrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub cmdShowChild_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdShowChild.Click
frmChild.ShowDialog()
Me.txtRetrievedData.Text = frmChild.getString
frmChild.Dispose()
End Sub
End Class
****************
Public Class frmChild
Public Property getString()
Get
Return Me.txtChildTextvalue.Text
End Get
Set(ByVal value)
End Set
End Property
Private Sub auxFrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub cmdReturnData_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdReturnData.Click
Me.Hide()
End Sub
End Class