I had to do this for a customer... this will scroll text inside of a textbox by removing the first character and placing it at the end of the string.
delegate for scrolling and class level variable
csharp
public delegate void ScrollTextboxCallback(string t);
string marqueeText = "This is only a test.";
Tread to start the marquee
csharp
Thread thread = new Thread(new ThreadStart(ScrollTextbox));
thread.Start();
ScrollTextbox method
csharp
private void ScrollTextBox()
{
string tempChar = string.Empty;
string tempText = string.Empty;
tempText = marqueeText + " "; // adds spaces at the end of the text so there is a clear ending to the text
while (true)
{
tempChar = tempText.SubString(0,1);
tempText = tempText.Remove(0,1) + tempChar;
textBox1.Invoke(new ScrollTextboxCallback(this.UpdateTextBox), new object[] { tempText });
Thread.Sleep(100); //lowering this value with make the marquee scroll faster
}
}
UpdateTextBox method
csharp
private void UpdateTextBox(string m_text)
{
textBox1.Text = m_text;
}
This post has been edited by eclipsed4utoo: 8 Oct, 2008 - 09:07 AM