RichText Box问题上的绘画方法 [英] Paint method on RichText Box Problem

查看:67
本文介绍了RichText Box问题上的绘画方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在richtextbox上绘图,所以我找到了以下代码:

I want To draw on richtextbox ,so I found this code :

private void IRTBDrawRectangle(Color RTBDrawColor, int RTBPointX, int RTBPointY, int RTBWidth, int RTBHeight)
       {

           System.Drawing.Pen MyPen = new System.Drawing.Pen(RTBDrawColor);
           System.Drawing.Graphics FormGraphics = null;
           SolidBrush MySolidBrush = null;
           RTBHeight = RTBHeight * 1 + 2;
           if (RTBDrawColor.A > 64)
           {
               MySolidBrush = new SolidBrush(Color.FromArgb(64, RTBDrawColor.R, RTBDrawColor.G, RTBDrawColor.B));
           }
           else
           {
               MySolidBrush = new SolidBrush(RTBDrawColor);
           }
           FormGraphics = this.richTextBox1.CreateGraphics();
           FormGraphics.DrawRectangle(MyPen, RTBPointX, RTBPointY, RTBWidth, RTBHeight);
           FormGraphics.FillRectangle(MySolidBrush, RTBPointX, RTBPointY, RTBWidth, RTBHeight);
           MyPen.Dispose();
           FormGraphics.Dispose();

       }


//但是,当我上下滚动Richtext时,我绘制的矩形(形状)消失并消失了.
我希望将其永久涂漆.


// but when I scroll the Richtext up or down the rectangle (shape) which i have draw go away and disappeared .
i want it to be paint permanently .

推荐答案

这可能对您有所帮助:
http://msdn.microsoft.com/en-us/magazine/cc188731.aspx [ ^ ]
this may help you:
http://msdn.microsoft.com/en-us/magazine/cc188731.aspx[^]


您好,

在方法内部调用this.richTextBox1.Refresh().

谢谢!!
Hi,

Call this.richTextBox1.Refresh() inside the method.

Thanks!!


这篇关于RichText Box问题上的绘画方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆