最近开发一个基于windows mobile 6.5的小程序,需在要一个自定义控件上绘制线条,采用了双缓冲的方法 ,但是程序运行时,发现滚动屏幕时,这根线条还是在闪烁,请看下面的代码 protected override void OnPanit(PaintEventArgs e){       Bitmap bmp = new Bitmap(this.width,this.height);        Graphic g = Graphics.FromImage(bmp);        g.Clear(Color.White);        g.DrawLine(Pens.Black, 2, 2, 100, 100);        e.Graphic.DrawImage(bmp);        bmp.Dispose();}请大家指点一下这段代码有什么问题
                    
                    
                1 回答
 
                    
                    
                            米琪卡哇伊
                            
                                
                            
                        
                        
                                                
                    TA贡献1998条经验 获得超6个赞
把 e.Graphic.DrawImage(bmp); 换成
this.CreateGraphics().DrawImage(bmp);
在你的控件初始化的时候添加下面的代码:
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
this.UpdateStyles();
- 1 回答
- 0 关注
- 335 浏览
添加回答
举报
0/150
	提交
		取消
	