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

Scrolling Text?

2 Answers 158 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Phillip Foster
Top achievements
Rank 1
Phillip Foster asked on 11 Oct 2010, 09:33 PM
Random question:

Is there a way to make this control do scrolling text?

example
textbox would contain:

"this is a.."
"his is a t"
"is is a te"
"s is a tes"
" is a test"
"is a test "

I'm not that was not necessary, but eh. 
Anyone know?'

2 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 11 Oct 2010, 10:20 PM
Hi,

As far as Im aware, there is no default support for this. You'd need to implement your own system for updating text in the textbox that would immitate scrolling text.

However, I'd have a look at the demo applications that are installed with the controls and use either a rad rotator or even a rad progress bar (where you can use your own image)
Hope that helps
Richard
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 11 Oct 2010, 11:05 PM
Hello Philip,

There is no telerik control that does this, but i have prepared a CustomRadTextBoxControl that will do this, please see the following example, it should help you accomplish your task:
using System;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    ScrollableRadTextBox radTextBox1 = new ScrollableRadTextBox();
 
    public Form1()
    {
        InitializeComponent();
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        radTextBox1.Dock = DockStyle.Top;
        this.Controls.Add(radTextBox1);
        radTextBox1.Text = "This is a test of the emergency broadcast systems";
        radTextBox1.StartScrolling(20);
 
        var stopButton = new RadButton();
        stopButton.Text = "Stop";
        this.Controls.Add(stopButton);
        stopButton.Dock = DockStyle.Bottom;
        stopButton.Click += new EventHandler(stopButton_Click);
 
        var startButton = new RadButton();
        startButton.Text = "Start";
        this.Controls.Add(startButton);
        startButton.Dock = DockStyle.Bottom;
        startButton.Click += new EventHandler(startButton_Click);
    }
 
    void stopButton_Click(object sender, EventArgs e)
    {
        radTextBox1.EndScrolling();
    }
 
    void startButton_Click(object sender, EventArgs e)
    {
        radTextBox1.StartScrolling(20);
    }
}
 
public class ScrollableRadTextBox : RadTextBox
{
    private Timer scrollTimer = new Timer();
 
    private string currentText;
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadTextBox).FullName;
        }
    }
 
    public ScrollableRadTextBox()
        : base()
    {
        scrollTimer.Interval = 200;
    }
 
    private void ScrollText(int noCharacters)
    {
        if (this.Text.Length == 0 || this.Text.Length < noCharacters)
        {
            return;
        }
 
        var pos = 0;
        currentText = Text;
        var tempText = currentText + " " + currentText;
        scrollTimer.Tick += delegate
            {
                if (pos - 1 > currentText.Length) pos = 0;
                Text = tempText.Substring(pos++, noCharacters);
            };
 
        scrollTimer.Start();
    }
 
    public void StartScrolling(int noCharacters)
    {
        this.ScrollText(noCharacters);
    }
 
    public void EndScrolling()
    {
        scrollTimer.Stop();
        this.Text = currentText;
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Tags
TextBox
Asked by
Phillip Foster
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Emanuel Varga
Top achievements
Rank 1
Share this question
or