Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I have tried to draw a line in a richtextbox and i have successfully draw the line but whenever i scroll the richtextbox and go back to the line i found it missing here is the code i am using to draw line:

C#
private void DrawLineInRichtextbox(RichTextBox rtb, Point p1)
{
     Pen pen = new Pen(Color.Black);
     Graphics graphics;
     graphics = richTextBox2.CreateGraphics();
     graphics.DrawLine(pen, p1.X, p1.Y, rtb.Width, p1.Y);
     pen.Dispose();
     graphics.Dispose();
}


Pleas tell me what is wrong with the darawline i need a permanent line in richtextbox.

Thanks in advance
Suheb Ahmad
New Delhi
INDIA
Posted
Updated 5-Jan-10 5:10am
v2

Hmm, Perhaps you need top add a 'redraw' event handler to the ligh or create a custom line object

~TheArch
 
Share this answer
 
Try to put your code inside the OnDraw() method
I supposed that you use VC++
 
Share this answer
 

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