style hyperlinks in html formatted RadLabel

8 posts, 0 answers
  1. erwin
    erwin avatar
    382 posts
    Member since:
    Dec 2006

    Posted 07 Oct 2016 Link to this post

    Hello

    - Are there means to style hyperlinks in a html formatted RadLabel similar to css (.hover, .visited etc.)? couldn't find anything in the docs.

    - When using a RadLabel with a hyperlink on a Rad Doc Document, the link seems to stay in .active mode after the webpage has opened. When I reopen the document the link goes into .visited style (as expected). I'd like it to revert to initial state or go into .visited state.

    Regards

    Erwin

  2. Dimitar
    Admin
    Dimitar avatar
    1936 posts

    Posted 10 Oct 2016 Link to this post

    Hello Erwin,

    Thank you for writing.

    Currently, such styles are not provided for the HTML-like text formatting. I have logged a feature request for this in our Feedback Portal. And I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.

    At this point to achieve a similar functionality you can create a LinkLabel control. Here is an example:
    class RadLinkLabel : RadLabel
    {
        bool visited;
      
        public RadLinkLabel()
        {
            this.Font = new Font("Segoe UI", 12, FontStyle.Underline);
            this.Text = "Telerik";
            this.ForeColor = Color.Blue;
            visited = false;
        }
      
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            Process.Start("www.telerik.com");
            visited = true;
            this.ForeColor = Color.FromArgb(128, 96, 204);
        }
      
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            this.ForeColor = Color.Black;
            this.Cursor = Cursors.Hand;
        }
      
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            if (visited)
            {
                this.ForeColor = Color.FromArgb(128, 96, 204);
            }
            else
            {
                this.ForeColor = Color.Blue;
            }
            this.Cursor = Cursors.Default;
        }
    }

    Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. erwin
    erwin avatar
    382 posts
    Member since:
    Dec 2006

    Posted 10 Oct 2016 in reply to Dimitar Link to this post

    Thanks Dimitar,

    I had already developed something similar derived from RadLabel for simple hyperlinks, but in this case the html formatting of RadLabel would have been handy to display a longer text with multiple hyperlinks in it.

    No big deal, I asked because I could have missed something in the docs.

    BTW: Might be a a good idea to provide a control similar to the Windows Forms Hyperlink control, with a similar API as a drop-in replacement.

    Using the Windows Forms Hyperlink control within RadDock leads to unpleasant effects probably because of missing support for double buffering. For example if a document within RadDock disables a Windows Hyperlink control in its initialization, the hyperlink gets painted immediately and appears before the rest of the documenent gets painted.

    Also it's almost impossible to properly align a RadLabel and a WinForms Hyperlink control in a form because of different text rendering.

    Another thing I have noticed is that using html formatting also changes the margin of the text in a RadLabel. That is if two RadLabel controls are aligned in the forms designer and one gets the text "ABC" it does not render the same way as "<html>ABC</html>". This I consider a bug.

    Regards

    Erwin

     

     

  4. Dimitar
    Admin
    Dimitar avatar
    1936 posts

    Posted 11 Oct 2016 Link to this post

    Hello Erwin,

    I have tested the standard LinkLabel inside RadDock, but I was unable to reproduce this. If you want us to further investigate it please open a new support ticket and attach a sample project that reproduces the issue.

    In addition, are there any features missing from the custom control from my previous post that you currently require? 

    As to the label alignment at hand, indeed there is a difference. This difference is caused because we are using two different primitives to paint the text (one for regular text and one for HTML). These primitives are rendering (measuring) the text differently and because of this, it is not aligned. Unfortunately, at this point, there is not much we can do about this. I would recommend adding the HTML tag to all labels in the same column, this way they will be aligned. 

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  5. erwin
    erwin avatar
    382 posts
    Member since:
    Dec 2006

    Posted 11 Oct 2016 in reply to Dimitar Link to this post

    Hi Dimitar, as I have changed all my former Winform Hyperlink controls to my homegrown controls based on RadLabel, I can no longer reproduce the issue. When you  set Enabled to false on a Winform Hyperlink control, it immediately paints itself. To see the effect, you need a complex RadDock document that takes some time to fully initialize. If during that time, the Document outline is already visible inside of RadDock, and your code disables the Hyperlink control, you will see the disabled Hyperlink immediately, before all of the double buffered Telerik Controls.

    The same is also true for the WinForms Splitter control. In the past I had discussions about this with Telerik Support, but that was with the previous Docking system, and fortunately Telerik now provides this functionality with RadSplitContainer.

    Anyway, these are minor issues and there are workarounds.

    Regards

    Erwin

  6. Dimitar
    Admin
    Dimitar avatar
    1936 posts

    Posted 12 Oct 2016 Link to this post

    Hi Erwin,

    Thanks for the detailed description of the case. I am glad that this is working fine with your custom control.

    Do not hesitate to contact us if you have other questions.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  7. Gone2TheDogs
    Gone2TheDogs avatar
    38 posts
    Member since:
    May 2016

    Posted 14 Feb Link to this post

    Are there any updates for adding links? I didn't see anything that looked like a LinkLabel.

     

  8. Dimitar
    Admin
    Dimitar avatar
    1936 posts

    Posted 15 Feb Link to this post

    Hi Bob,

    My first post shows how you can implement LinkLabel.

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top