Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jun 30, 2010 11:43 pm Post subject: |
|
|
Is this the effect you mean?
This is because Virtual Trees cell editors are primary designed to support text editors - where having the background set to the selected color while editing would be very distracting.
If you don't like this effect there are a couple of alternatives:
1. Don't use an editor control - simply change the Column.CellStyle font (underline) and color to make it appear like a link then handle the CellClick event. The only problem with this solution is that the cursor doesn't change to a hand like it does for a link label when you hover.
2. Use a custom cell widget to implement link behaviour. Below is some code for a LinkWidget that will look and behave like a link label.
Code: | Public Class LinkWidget
Inherits CellWidget
Private mLinkStyleDelta As New StyleDelta
Public Sub New(ByVal sRowWidget As RowWidget, ByVal sColumn As Column)
MyBase.New(sRowWidget, sColumn)
mLinkStyleDelta.Font = New Font("Microsoft Sans Serif", 8.25, FontStyle.Underline)
mLinkStyleDelta.ForeColor = Color.Blue
End Sub
Public Overrides Function GetUnselectedStyle() As Style
Return New Style(MyBase.GetUnselectedStyle(), mLinkStyleDelta)
End Function
Public Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.OnClick(e)
' handle link logic here
End Sub
Public Overrides Sub OnMouseEnter(ByVal e As System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseEnter(e)
WidgetControl.Cursor = Cursors.Hand
End Sub
Public Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
WidgetControl.Cursor = Cursors.Default
End Sub
End Class |
To use the LinkWidget you either need to inherit a new class from VirtualTree and override the CreateCellWidget method or alternatively set the CellWidgetCreator property in the form that contains the VirtualTree control, as shown below:
Code: | Public Sub New()
InitializeComponent()
_virtualTree.CellWidgetCreator = AddressOf CreateCellWidget
End Sub
Private Function CreateCellWidget(ByVal sRowWidget As RowWidget, ByVal sColumn As Column) As CellWidget
' only use the LinkWidget for specific columns
'
If sColumn Is colAddress Then
Return New LinkWidget(sRowWidget, sColumn)
Else
Return New CellWidget(sRowWidget, sColumn)
End If
End Function |
Quote: | Also is there a way to upload images if you need a clear explanation? |
Yes you can upload your image to [url]tinypic.com[/url] (or other image repositories) and then link using the IMG tag. _________________ Infralution Support |
|