Finding Out Parent Control

  • Thread starter Thread starter Barkingmadscot
  • Start date Start date
B

Barkingmadscot

How do you find out the name of the parant control of the control you
are working working with

I have try

me.parent.name.tostring() ..... etc

any help would be great ta
 
Barkingmadscot said:
How do you find out the name of the parant control of the control you
are working working with

"Working with" at what point?
I have try
me.parent.name.tostring() ..... etc

Unless you're deriving your own Control classes, "Me" should refer to
the Class (i.e. Form) in which you're working which, hopefully, won't
/have/ a Parent Control.

Inside, say, a Control's Event Handler, you'd use:

Private Sub XYZ_Ev( ByVal sender as Object, ByVal e As EventArgs ) _
Handles XYZ.Ev [, ...]

If TypeOf sender Is Control Then
Dim parent As Control _
= DirectCast( sender, Control ).Parent

If parent IsNot Nothing Then
. . .
End If
End If
End Sub

HTH,
Phill W.
 
Barkingmadscot said:
How do you find out the name of the parant control of the control you
are working working with

I have try

me.parent.name.tostring() ..... etc

any help would be great ta

Without error checking:

\\\
MsgBox(Me.ActiveControl.Parent.Name)
///
 
Back
Top