This is a migrated thread and some comments may be shown as answers.

Scrolling RadTextBox

3 Answers 260 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 01 Feb 2013, 03:57 PM
Hello,

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.

Terry


3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 06 Feb 2013, 04:49 PM
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,
Plamen
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Danny
Top achievements
Rank 1
answered on 02 May 2018, 03:55 PM

Hi,

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....

Dan

0
Dimitar
Telerik team
answered on 03 May 2018, 11:45 AM
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
    radTextBox1.ScrollToCaret()
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
    radTextBoxControl1.ScrollToCaret()
 
End Sub

I hope this will be useful. 

Regards,
Dimitar
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.
Tags
TextBox
Asked by
Terry
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Danny
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or