Single Line RichTextBox

2 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 19 Sep 2014 Link to this post

    Is it possible to have a single line rich text box without showing scrollbars?

    I ideally want to use it for the user to enter a hyperlink and click on it to go to that web page.

    Thanks

    Andez
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 24 Sep 2014 Link to this post

    Hello Andez,

    Thank you for writing.

    This is possible but it is not recommended because if the text length exceeds the control length you will be unable to properly scroll and see the entire text:
    void Form1_Load(object sender, EventArgs e)
    {
        radRichTextBox1.AcceptsReturn = true;
        radRichTextBox1.AutoScroll = false;
     
        radRichTextBox1.RichTextBoxElement.VScrollBar.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
        radRichTextBox1.RichTextBoxElement.VScrollBar.RadPropertyChanging += VScrollBar_RadPropertyChanging;
    }
     
    void VScrollBar_RadPropertyChanging(object sender, Telerik.WinControls.RadPropertyChangingEventArgs args)
    {
        if (args.Property.Name == "Visibility")
        {
            args.Cancel = true;
        }
    }

    Directly entering link in the text box will not insert it. To insert a hyperlink you can use the insert hyperlink method or show the insert hyperlink dialog:
    private void radButton1_Click(object sender, EventArgs e)
    {
        radRichTextBox1.InsertHyperlink(new HyperlinkInfo() { NavigateUri = "www.telerik.com" }, "Telerik");
        //or
        radRichTextBox1.DocumentView.ShowInsertHyperlinkDialog();
    }

    I hope this helps.

    Regards,
    Dimitar
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top