Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how do I count the items inside rictextbox
and display it on a label.


for example like listbox


C#
label1.text = listbox1.items.count();


how do i do this with richtextbox
Posted
Comments
BillWoodruff 26-Feb-14 21:17pm    
What do you want to count in a RichTextBox: the number of words; or, the number of spaces ?
JB0301 26-Feb-14 21:18pm    
the number of rows only
Dave Kreskowiak 26-Feb-14 22:22pm    
A RichTextBox doesn't have "rows". It has "lines" which may or may not be the number of lines you see on screen.

1 solution

Try this:
C#
YourLabel.Text = YourRichTextBox.Lines.Length.ToString();
Keep in mind that if word-wrap is enabled, that may effect the way the end-user perceives the number of lines in a RichtTextBox.
 
Share this answer
 
Comments
Karthik_Mahalingam 26-Feb-14 23:32pm    
5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900