VB.NET Parent Form Reference
I have two forms on my web page which I manage it via vb. I had designed them in vb and now planing to migrate to vb.net. But before that I want to ensure that the migration will not affect the forms. How can I deal with forms when I upgrade the application. The other thing I want to know that what are the ways by which I can get a reference to a parent form. Because there some relation between both the forms.
Re: VB.NET Parent Form Reference
Here is a simple solution for your issue of form reference. You want to set up reference for the parent form related with the other one. Whenever vfp is started up a object name _screen is created. The most important custom property of _screen is Active form. Like you have a process called for different forms, so will simply pass a parameter or two. But if the process needs a access properties or method when the function is called then you have to give it reference to the form. See the sample below :
DO myproc WITH ThisForm
and in the procedure you need a corresponding parameter
FUNCTION myProc( toForm )
Re: VB.NET Parent Form Reference
After migration the way dealing with forms will be changed. Instead of loading and showing a form in the older way here you will have to create an instance of the form. After that only you can manipulate the from object. Yo had mentioned that you have two forms. Here Form2 is linked with Form1. When clicked on button in form 1 the second one comes up. I will assume the button is called as TheForm2 button. Now view the sample code here :
Code:
Private Sub TheForm2Button_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles TheForm2Button.Click
Dim F2 As New Form2()
F2.Show()
End Sub
Re: VB.NET Parent Form Reference
I will provide you with a basic and simple example to work with forms after upgrade. This one is the easy way. The below codes enables the user to reach to the second form and closing the first one. The below syntax will used for the purpose :
Code:
Private Sub SecondFormButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles SecondForm.Click
Dim F2 As New Form2()
F2.ShowDialog(Me)
End Sub