Control that adds properties to other controls

  • Thread starter Thread starter Johnny Jörgensen
  • Start date Start date
J

Johnny Jörgensen

Can anybody tell me how to make a user control add properties to other
controls (e.g. like when the ToolTip control adds a ToolTip on ToolTip1
property to the other visual controls)?

Cheers
Johnny J.
 
Thanks Ray,

I have now found out how to add the propery to different control types, and
it works like a charm. I've got one small problem, though:

My control is inherited from a normal System.Windows.Forms.Button, and I
want the control to add the property to other types of controls, but also to
other Button controls, but not my own inherited button control.

I try to check for that in my code:

Function CanExtend(ByVal target As Object) As Boolean Implements
IExtenderProvider.CanExtend
Dim bReturn As Boolean = False

If TypeOf target Is Control Then

If TypeOf target Is TextBox Then bReturn = True

If TypeOf target Is Button and Not TypeOf target Is Me Then bReturn =
True

End If

Return bReturn

End Function


That doesn't work, the property is even added to my own control. Neither
does this work:

Function CanExtend(ByVal target As Object) As Boolean Implements
IExtenderProvider.CanExtend
Dim bReturn As Boolean = False

If TypeOf target Is Control And Not TypeOf target Is MyButtonType Then

If TypeOf target Is TextBox Then bReturn = True


If TypeOf target Is Button and not(TypeOf target Is Me) Then bReturn =
True

End If

Return bReturn

End Function



What am I doing wrong?

Cheers,
Johnny J.
 
Back
Top