Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code:
C#
int contents = richTextBox1.Lines.Length;

C#
label1.text= richTextBox1.Lines[contents - 1];


however it is returning a null value. how can I resolve this
any answer would be appreciated
Posted
Updated 5-Mar-14 16:20pm
v2

1 solution

Try this out,
C#
string LastLineText = richTextBox1.Lines[richTextBox1.Lines.Count - 1];
Label1.Text = LastLineText;

I have not tested yet, but this should work. :)
-KR
 
Share this answer
 
Comments
JB0301 5-Mar-14 22:31pm    
its not working :(
Krunal Rohit 5-Mar-14 23:29pm    
have you tried with Breakpoint ?

-KR
JB0301 6-Mar-14 19:53pm    
what's that? sorry i have no idea when it comes to RTBs.

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