troubleshooting Question

CType(Me.ParentForm, Form1).control1.Text = "Title bar text"

Avatar of Ess Kay
Ess KayFlag for United States of America asked on
Programming.NET ProgrammingVisual Basic.NET
9 Comments1 Solution496 ViewsLast Modified:
i have two forms

Form1 and Form2

Form1 has a panel. It loads form2

Form2 has code like this

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

'Title of Control1
CType(Me.ParentForm, Form1).control1.Text = "Title bar text"

End Sub

Needless to say this works fine

Here comes the problem:
I added a new form: Form3
also with a panel with Form2 inside

now i have a problem with this CType(Me.ParentForm, Form1).control1.Text

I would also like to have this fixed to accept any future parent form, instead of writing something like

if = "form1" then
    CType(Me.ParentForm, Form1).control1.Text = "bla1"
else if = "form2" then
   CType(Me.ParentForm, Form2).control1.Text = "bla bla2"
else if infiniti
    CType(Me.ParentForm, FormInfini).control1.Text  = "blablablafiniti"
end if

please help
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros