Skip to content

TextView

The TextView widget displays multi-line text with scrolling capabilities. Perfect for logs, chat messages, or any scrollable text content.

TextView maintains a list of text lines and provides scrolling functionality. It’s ideal for displaying logs, chat messages, or any content that may exceed the visible area.

Whether to automatically scroll to the bottom when new lines are added (default: true).

textView.AutoScroll = true;

Whether to wrap long lines (default: false).

textView.WordWrap = true;

The current scroll offset (number of lines scrolled).

int offset = textView.ScrollOffset;

The total number of lines.

int count = textView.LineCount;

Adds a line of text to the view.

textView.AppendLine("New message");

Adds multiple lines of text.

textView.AppendLines(new[] { "Line 1", "Line 2", "Line 3" });

Sets the text content, replacing all existing lines.

textView.SetText("Line 1\nLine 2\nLine 3");

Clears all text.

textView.Clear();
  • ScrollUp(int lines = 1): Scroll up
  • ScrollDown(int lines = 1): Scroll down
  • ScrollToTop(): Scroll to top
  • ScrollToBottom(): Scroll to bottom
  • Up Arrow: Scroll up one line
  • Down Arrow: Scroll down one line
  • Page Up: Scroll up one page
  • Page Down: Scroll down one page
  • Home: Scroll to top
  • End: Scroll to bottom
var textView = new TextView
{
X = 2,
Y = 2,
Width = 70,
Height = 15,
ForegroundColor = Color.White,
BackgroundColor = Color.Black,
AutoScroll = true
};
textView.AppendLine("[System] Welcome!");
textView.AppendLine("[User] Hello");
textView.AppendLine("[Bot] Hi there!");
// Disable auto-scroll to allow manual scrolling
textView.AutoScroll = false;
textView.ScrollToTop();
textView.AppendLine($"[{DateTime.Now:HH:mm:ss}] {username}: {message}");
textView.AppendLine($"[{level}] {message}");