• 10
• 9
• 13
• 10
• 18

# [web] [Silverlight] Auto-scrolling through a text box

This topic is 3079 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, if this should be in the .NET forum I apologise, I wasn't sure. I am using Silverlight with C# to create an application. One of the elements is an output window,
 TextBox sudoOutputWindow;

. Throughout the running of the application, lines are added on to the text box:
 sudoOutputWindow.Text += "example line /n"

Anyhow, what I want to be able to do is get the text box to scroll down once the lines reach the bottom of the box so the user can always see the latest line. I couldn't find any function in the TextBox class, so is there some other way?

// If there is current text and it does not end in a newline, add one.if (!string.IsNullOrEmpty(outputWindow.Text) && !outputWindow.Text.EndsWith(Environment.NewLine)) {	outputWindow.Text += Environment.NewLine;}// Append the text.outputWindow.Text += DateTime.Now.ToString();// Set the selection to the end of the text, zero length.outputWindow.SelectionLength = 0;outputWindow.SelectionStart = outputWindow.Text.Length;