首页 相关文章 对C#中的TreeView添加背景图

对C#中的TreeView添加背景图

  在微软的.NET 的Forms窗口控件中,比如Treeview和ListView,仅仅是对通用控件的简单封装,因此他们不正常的引发Paint事件。 微软所发布内容中,能看到的唯一建议就是设置控件的ControlStyles.UserPaint类型,然后自己为控件做所有的绘图操作。 (译注:老外提供了一个TreeViewWithPaint控件类,派生自TreeView类,提供了Paint事件的挂接。)

  一、为了解决这个问题,我们在类内部使用了一个基于Bitmap类的Graphics对象。当任何窗口重新定义大小时候,对象都会重建。

  

//Recreate internal graphics objectprotected override void OnResize( System.EventArgs e ){ if( internalBitmap == null || internalBitmap.Width != Width || internalBitmap.Height != Height ) {  if( Width != 0 && Height != 0 )  {   Dispose...[ 查看全文 ]

2016-02-19 标签:

对C#中的TreeView添加背景图的相关文章

手机页面
收藏网站 回到头部