用C#listview控件Details类型,发现当拉动表头调整列宽度过程时,listview会重画,造成不停的闪烁
1个回答
展开全部
使用双缓冲,重写
ListView :class DoubleBufferListView : ListView
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
public partial class Form1 : Form
{
private int counter = 0;
public Form1()
{
InitializeComponent();
}
DoubleBufferListView lv = new DoubleBufferListView();
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = false;
this.Controls.Add(lv);
lv.View = View.Details;
lv.GridLines = true;
lv.BackColor = Color.Silver;
lv.Columns.Add("aa");
lv.Columns.Add("bb");
lv.Columns.Add("cc");
lv.Height = 300;
lv.Width = 300;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
lv .Items.Add(counter.ToString());
counter++;
}
ListView :class DoubleBufferListView : ListView
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
public partial class Form1 : Form
{
private int counter = 0;
public Form1()
{
InitializeComponent();
}
DoubleBufferListView lv = new DoubleBufferListView();
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = false;
this.Controls.Add(lv);
lv.View = View.Details;
lv.GridLines = true;
lv.BackColor = Color.Silver;
lv.Columns.Add("aa");
lv.Columns.Add("bb");
lv.Columns.Add("cc");
lv.Height = 300;
lv.Width = 300;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
lv .Items.Add(counter.ToString());
counter++;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询