Current number of lines visible in RichTextBox???? 
Author Message
 Current number of lines visible in RichTextBox????

How can you tell how many lines are currently being displayed
(visible) in a RichTextBox?  

This can vary based on which font size is used, so it does not seem
straight forward to figure out?  Am I forced to calculate this value
based on the current font point size and the known height of the
RichTextBox?    There must be an easier way.

UncleT



Sun, 25 Aug 2002 03:00:00 GMT  
 Current number of lines visible in RichTextBox????
You can get an approximation using

  Form1.Font = RichTextBox1.Font
  Form1.FontSize = RichTextBox1.Font.Size
  Debug.Print RichTextBox1.Height / TextHeight("W")

Be aware, however, there is no "exact" answer because a RichTextBox can be
sized in such a way that on part of the last line is visible. In any event,
you can play around with various rounding options to get what you want.
(Another possible fly in the ointment is if you use text of differing sizes,
then the above won't work.)

Rick


Quote:

> How can you tell how many lines are currently being displayed
> (visible) in a RichTextBox?

> This can vary based on which font size is used, so it does not seem
> straight forward to figure out?  Am I forced to calculate this value
> based on the current font point size and the known height of the
> RichTextBox?    There must be an easier way.

> UncleT



Mon, 26 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Current line number in a RichTextBox.

2. Current line number in a RichTextBox.

3. Current line number in a RichTextBox.

4. Get last visible line of RichTextBox

5. Q:How to get the number of lines visible in rich textbox control

6. RichTextBox Line Numbers

7. Go To Line Number (in RichTextBox)

8. Get line number in RichTextBox

9. Number of lines in a richtextbox

10. Current Line Number in an Access Module

11. Finding current line number in Access 97 module

12. Number of current 'line' (para)

 

 
Powered by phpBB® Forum Software