When you play the game, you probably noticed the messages RichTextBox scrolls to the top after you add more messages to it. So, the player has to manually scroll to the bottom to see the latest message.
We want to make it easier for the player.
How to scroll to the bottom of a RichTextBox
Step 1: Add this new ScrollToBottomOfMessages() function to the code in the SuperAdventure.cs class:
private void ScrollToBottomOfMessages()
rtbMessages.SelectionStart = rtbMessages.Text.Length;
Step 2: After you add more to rtbMessages.Text, call the ScrollToBottomOfMessages() method.
Source code for this lesson
Get it from GitHub: https://gist.github.com/ScottLilly/21997dc89b21c629c449
Previous lesson: Lesson 18.1 – Future enhancements for the game
Next lesson: Lesson 19.2 – Use a calculated value for a property
All lessons: Learn C# by Building a Simple RPG Index