paint事件中图像一闪而消失的问题 画图的Graphics可能选的不合适。应该使用它的参数里的Graphics(e.Graphics); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void CreateForm() { //创建画板 Graphics g = lblForm.CreateGraphics(); //this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); try { g.Clear(Color.White); Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular); Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, lblForm.Width, lblForm.Height), Color.Blue, Color.Blue,1.2f,true); //填充画板背景色 g.FillRectangle(Brushes.White, 0, 0, lblForm.Width, lblForm.Height); //画图片边框线 g.DrawRectangle(new Pen(Color.Blue), 0, 0, lblForm.Width - 1, lblForm.Height - 1); Pen mypen = new Pen(brush, 1); Pen mypen2 = new Pen(Color.Red, 2); //绘制纵向线条 int x = 20; for (int i = 0; i < 12; i++) { g.DrawLine(mypen, x, 30, x, 200); x += 20; } } finally { g.Dispose(); } lblForm是什么?是Label?你为什么不添加Label的Paint事件呢?把画的代码放到Paint里,不要CreateGraphics。 求C#屏蔽键盘的部分功能键的代码 WCF、Webservice和Socket 在类中使用Server.MapPath问题 一个winform加载25个小的pictureBox控件,显示会很慢,有办法解决吗? 用OWC做柱图,无法正确显示百分比 C#控制鼠标键盘在屏幕上执行某个程序 绘制图标问题 在线急等!!!如何把一个表中的数据字段绑订到模板列的DropDownList中??? .net2003中智能设备应用程序中的dataGrid绑定sqlce数据库中数据的问题 急问:有关相对路径问题 C#中 有哪些模拟键盘鼠标的函数(包括API) 制作报表用那种方法比较好?
{
//创建画板
Graphics g = lblForm.CreateGraphics();
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); try
{
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);
Font font2 = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, lblForm.Width, lblForm.Height), Color.Blue, Color.Blue,1.2f,true);
//填充画板背景色
g.FillRectangle(Brushes.White, 0, 0, lblForm.Width, lblForm.Height);
//画图片边框线
g.DrawRectangle(new Pen(Color.Blue), 0, 0, lblForm.Width - 1, lblForm.Height - 1); Pen mypen = new Pen(brush, 1);
Pen mypen2 = new Pen(Color.Red, 2); //绘制纵向线条
int x = 20;
for (int i = 0; i < 12; i++)
{
g.DrawLine(mypen, x, 30, x, 200);
x += 20;
}
}
finally
{
g.Dispose();
}