Richtextbox中的画线问题 [英] Problem with drawline in Richtextbox
本文介绍了Richtextbox中的画线问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我尝试在richtextbox中画一条线,并且成功绘制了这条线,但是每当我滚动richtextbox并回到这条线时,我发现它丢失了,这里是我用来画线的代码:
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:
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();
}
请告诉我darawline有什么问题,我需要在richtextbox中添加永久行.
在此先感谢
Suheb Ahmad
新德里
INDIA
Pleas tell me what is wrong with the darawline i need a permanent line in richtextbox.
Thanks in advance
Suheb Ahmad
New Delhi
INDIA
推荐答案
嗯,也许您需要在顶部添加一个重绘"事件处理程序或创建自定义线对象
〜TheArch
Hmm, Perhaps you need top add a ''redraw'' event handler to the ligh or create a custom line object
~TheArch
尝试将您的代码放入OnDraw()方法中
我以为你用的是VC ++
Try to put your code inside the OnDraw() method
I supposed that you use VC++
这篇关于Richtextbox中的画线问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文