Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by thk123 Oct 14, 2009 at 6:56 AM 0 replies 3.5k views
Original Post
thk123
thk123
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?
-thk123botworkstudio.blogspot.com - Shamelessly advertising my new developers blog ^^
benryves
benryves
I'm not sure if there's a better way of doing it, but this works for me:

// 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;
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.