all groups > dotnet windows forms designtime > may 2005 >
You're in the

dotnet windows forms designtime

group:

how to inherit LinkLabel control


Re: how to inherit LinkLabel control Tim Wilson
5/3/2005 12:00:00 AM
dotnet windows forms designtime:
The code you posted has some compilation issues. But here is the modified
code that I used and it seemed to work as expected.

Public Class HoverLinkLabel
Inherits System.Windows.Forms.LinkLabel

Public Sub New()
MyBase.New()
End Sub

Private _hoverColor As Color = MyBase.LinkColor
Private _linkColor As Color = MyBase.LinkColor

Public Property HoverColor() As Color
Get
Return _hoverColor
End Get
Set(ByVal Value As Color)
_hoverColor = Value
End Set
End Property

Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
Me.LinkColor = _hoverColor
End Sub

Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
Me.LinkColor = _linkColor
End Sub
End Class

--
Tim Wilson
..Net Compact Framework MVP

how to inherit LinkLabel control Michael Palmer
5/3/2005 11:07:44 AM
I'm trying to inherit/extend the standard LinkLabel control so I can add a
couple of additional things to it... but, I can't get it to display on any
forms. Do I need a custom designer? What am I missing? Here's my code...


Public Class HoverLinkLabel

Inherits System.Windows.Forms.LinkLabel

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

#End Region

Private _hoverColor As Color = ControlsHelper.GetHoverLinkColor

Private _linkColor As Color = Me.LinkColor

Public Property HoverColor() As Color

Get

Return _hoverColor

End Get

Set(ByVal Value As Color)

_hoverColor = Value

End Set

End Property

Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)

MyBase.OnMouseEnter(e)

Me.LinkColor = _hoverColor

End If

End Sub

Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)

MyBase.OnMouseLeave(e)

Me.LinkColor = _linkColor

End If

End Sub

End Class


Re: how to inherit LinkLabel control joeycalisay
5/4/2005 12:00:00 AM
Only UserControls within the same solution shows up at the ToolBox
(UserControl) Section. If you are developing your own control, you have to
add it explicitly browsing to the assembly (DLL) containing the control and
selecting it from the list.

--
Joey Calisay
http://spaces.msn.com/members/joeycalisay/


[quoted text, click to view]

Re: how to inherit LinkLabel control joeycalisay
5/4/2005 12:00:00 AM
were you able to add it in the toolbox?

--
Joey Calisay
http://spaces.msn.com/members/joeycalisay/


[quoted text, click to view]

Re: how to inherit LinkLabel control Michael Palmer
5/4/2005 8:40:38 AM
Hi Tim... thanks for your reply. The compilation issue stems from a missing
ControlsHelper class. I failed to remove that before posting. The problem I
was having was that VS.NET wasn't letting me put my derived LinkLabel
control onto a form. But... using the same code, I'm able to choose the
control from within another project. Weird.... it won't show up in the
toolbox like my other controls unless I force it to. Then, when I try to
insert it in a form, it simply does nothing. VS won't draw it on a form.
So.... I don't know what's wrong. None of my other controls have this
problem. But....luckily I'm able to use it from my other project, which is
how I need it anyway.

Thanks for your input, I appreciate it.

-Michael

[quoted text, click to view]

Re: how to inherit LinkLabel control Michael Palmer
5/4/2005 8:41:55 AM
Hey Joey...

The control won't show up in the toolbox by itself like other custom
controls do... I'm not sure why. I have to explicitly add it. Any idea why?

[quoted text, click to view]

Re: how to inherit LinkLabel control v-jetan NO[at]SPAM online.microsoft.com (
5/6/2005 12:00:00 AM
Hi Michael,

Have you tried Tim's modified sample code? Does your problem still go with
Tim's sample code?
Currently, I suggest you create a new project and paste your sample code,
does this problem occur? Also, you may test your project on some other
machines. Does this problem go away?

With these tests, we can determine if this problem is machine-specific or
project-specific. If you have any further concern, please feel free to
feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button