Peter Allen
asked on
Access Public Properties of a Form created dynamically in VB.NET
Experts,
I was successful in createing the UI that I wanted for a form I am working on. The UI has a ToolStrip with the buttons for the various pages. To keep things simple lets say FormOne, Form2, Form3, etc.
As I select the desired button in the ToolStrip the appropriate Form is loaded in a Form Panel. Here is how the form shows in the Panel:
Dim f_PanelForm As Form = clsMod_CreateObjects.Creat eForm(p_sW indowPanel FormName)
p_sWindowPanelFormVisible = "Show"
f_PanelForm.TopLevel = False
f_PanelForm.Parent = Me
Panel_Form.Controls.Add(f_ PanelForm)
f_PanelForm.Show()
What I also have are some Public Properties on theform I just loaded and displayed. How would I reference these Public Properties. I've hear of using the Form's modifier, but I am not quite sure how to do this when my variable f_PanelForm holds the reference.
Thank you in advance for the assistance.
I was successful in createing the UI that I wanted for a form I am working on. The UI has a ToolStrip with the buttons for the various pages. To keep things simple lets say FormOne, Form2, Form3, etc.
As I select the desired button in the ToolStrip the appropriate Form is loaded in a Form Panel. Here is how the form shows in the Panel:
Dim f_PanelForm As Form = clsMod_CreateObjects.Creat
p_sWindowPanelFormVisible = "Show"
f_PanelForm.TopLevel = False
f_PanelForm.Parent = Me
Panel_Form.Controls.Add(f_
f_PanelForm.Show()
What I also have are some Public Properties on theform I just loaded and displayed. How would I reference these Public Properties. I've hear of using the Form's modifier, but I am not quite sure how to do this when my variable f_PanelForm holds the reference.
Thank you in advance for the assistance.
ASKER
mas_oz2003,
Unfortunately this was not quite clear givem my code above. Can you elaborate please?
Unfortunately this was not quite clear givem my code above. Can you elaborate please?
Can you tell me what the form name is?
e.g. Given the form below
Public Class Form1
Public ReadOnly Property MyTextBox() As TextBox
Get
Return textBox1
End Get
End Property
'Assumption: Dynamic forms are created as:
Dim f_PanelForm As Form = clsMod_CreateObjects.Creat eForm("For m1")
' Cast to Form1
Dim cast_Form As Form = CType(f_PanelForm , Form1)
' then you can call prop
' cast_Form.MyTextBox()
e.g. Given the form below
Public Class Form1
Public ReadOnly Property MyTextBox() As TextBox
Get
Return textBox1
End Get
End Property
'Assumption: Dynamic forms are created as:
Dim f_PanelForm As Form = clsMod_CreateObjects.Creat
' Cast to Form1
Dim cast_Form As Form = CType(f_PanelForm , Form1)
' then you can call prop
' cast_Form.MyTextBox()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeproject.com/Articles/5044/Cheat-Sheet-Casting-in-VB-NET-and-C