Scrolling RadTextBox

4 posts, 0 answers
  1. Terry
    Terry avatar
    39 posts
    Member since:
    Sep 2007

    Posted 01 Feb 2013 Link to this post


    I'll try and explain what I'm after. I have a multiline RadTextBox, (takes about 7 lines of text). I dont want to show scroll bars as I start to type. When the text gets to the 8th line either via enter or wordwrap to make the vertical scroll bar appear.

    I can do this with a RichTextbox but need to use a RadTextBox

    Is this possible?

    I have tried using the .lines property but that doesn't increment when using word wrap.

    Any help much appreciated.


  2. Plamen
    Plamen avatar
    132 posts

    Posted 06 Feb 2013 Link to this post

    Hi Terry,

    Thank you for writing.

    I would suggest that you use RadTextBoxControl that supports the desired feature. Moreover, the scrollbars that appear for RadTextBoxControl are our own, so they match our styles, while in the case of RadTextBox, we are hosting the standard TextBox control, hence the functionality and ScrollBars there are the standard ones. Here is a sample code snippet that will allow you to achieve the desired behavior:
    this.radTextBoxControl1.Multiline = true;
    this.radTextBoxControl1.WordWrap = true;
    this.radTextBoxControl1.VerticalScroll.Enabled = true

    I hope this helps.

    All the best,
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. Danny
    Danny avatar
    11 posts
    Member since:
    May 2018

    Posted 02 May 2018 in reply to Plamen Link to this post


    Sorry for my idiot question, but I cannot really find a solution. Is there any way to control a multi line text box in order to write many lines of text (separated with VBCRLF) into a text box/text box control and at the end the cursor of the scroll bar to be positioned at the bottom of the text area? (in my try, the cursor of the scroll bar remains in the first position / first line of the text area)

    Thanks in advance, and once again, sorry if my question seems silly....


  4. Dimitar
    Dimitar avatar
    2938 posts

    Posted 03 May 2018 Link to this post

    Hello Dan,

    The code for both controls is similar. For example, you can use the SelectionStart property and the ScrollToCaret method:
    Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.radTextBox1.Multiline = True
        Me.radTextBox1.WordWrap = True
        Me.radTextBox1.ScrollBars = ScrollBars.Vertical
        Dim sb As New StringBuilder()
        For i As Integer = 0 To 99
            sb.AppendLine("Line" & i)
        Next i
        radTextBox1.Text = sb.ToString()
        radTextBox1.SelectionStart = radTextBox1.Text.Length
    End Sub
    Private Sub radButton2_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.radTextBoxControl1.Multiline = True
        Me.radTextBoxControl1.WordWrap = True
        Me.radTextBoxControl1.VerticalScroll.Enabled = True
        Dim sb As New StringBuilder()
        For i As Integer = 0 To 99
            sb.AppendLine("Line" & i)
        Next i
        radTextBoxControl1.Text = sb.ToString()
        radTextBoxControl1.SelectionStart = radTextBoxControl1.Text.Length
    End Sub

    I hope this will be useful. 

    Progress Telerik
    Try our brand new, jQuery-free Angular 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