`
xiaoer_1982
  • 浏览: 1821107 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

无闪烁的listview

阅读更多

Q:http://topic.csdn.net/u/20071205/15/116fa433-69bc-418d-a31c-3c279abc8007.html

A:

public partial class Form1:Form
... {

class DoubleBufferListView:ListView
... {
public DoubleBufferListView()
... {
SetStyle(ControlStyles.DoubleBuffer
| ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true );
UpdateStyles();
}

}



public Form1()
... {
InitializeComponent();
}


DoubleBufferListViewlv
= new DoubleBufferListView();
private void Form1_Load( object sender,EventArgse)
... {

this .Controls.Add(lv);
lv.Height
= 300 ;
lv.Width
= 300 ;
new System.Threading.Thread( new System.Threading.ParameterizedThreadStart(doAdd)).Start();
}



void doAdd( object obj)
... {
if ( this .InvokeRequired)
... {
this .Invoke( new System.Action < object > (doAdd), new object [] ... {obj} );
}

else
... {
for ( int i = 0 ;i < 100 ;i ++ )
... {
this .lv.Items.Add( new ListViewItem( " jinjazz " + this .lv.Items.Count.ToString()));
System.Threading.Thread.Sleep(
10 );
Application.DoEvents();
}

}

}

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics