Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Custom Editor background color

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
morgenweck



Joined: 09 Jun 2010
Posts: 21

PostPosted: Wed Jun 30, 2010 1:00 pm    Post subject: Custom Editor background color Reply with quote

I'm having a bit of trouble setting the background color of a Linklabel custom editor. When I select a row everything looks fine.
however when I click on "edit" then a small rectangle shows around the label with a different color background and when the control loses focus then the linklabel maintains its background while the row changes to its non focus color. I have the setting for the editor to "UseCellHeight" to false and background color to Transparent. Can you point me in the right direct so the background color looks like the rest of the cells/row? Thanks

Also is there a way to upload images if you need a clear explanation?

Thanks
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jun 30, 2010 11:43 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group