Hi Rick Delhommer,
I would explain the two areas at first, then explain how I use them to calculate the visible lines.
The text areas:
1. Visible text area: The height of the RichTextBox. We would see the visible lines in this area. For example, we can see nine lines in this area if the 10th line is hidden under the bottom edge of the RichTextBox.
2. Total text area: The height of the area in which all the lines can be displayed. TextRender can draw text on a control or a form. It can also measure the text. In most cases, before we draw the text, we can use MeasureText to get a rectangle so that all the characters in the text can be displayed in this area. Then we can allocate enough spaces to display the text. For example, if there are 13 lines in the text of the RichTextBox, the rectangle returned by MeasureText can display all the 13 lines.
These are the steps to calculate the visible lines:
1. Get the height of the visible text area and the total text area.
2. Calculate the visible rate: visible height / total height. In other words, rate = visible lines / total lines.
3. Get the total lines and calculate the visible lines by using this formula: visible lines = total lines * rate.
You can get more information about TextRender from
http://msdn.microsoft.com/en-us/library/system.io.textreader.aspx.
Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.