public ListViewNF(IContainer container)
{
container.Add(this);
InitializeComponent();
//Activate double buffering
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint, true);
//Enable the OnNotifyMessage event so we get a chance to filter out
// Windows messages before they get to the form's WndProc
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
}
protected override void OnNotifyMessage(Message m)
{
//Filter out the WM_ERASEBKGND message
if (m.Msg != 0x14)
{
base.OnNotifyMessage(m);
}
}
In the Load event:
private void Form1_Load(object sender, EventArgs e)
{
ListViewNF nf = new ListViewNF();
}
I'm getting error on the line inside the ListViewNF
:
InitializeComponent();
Severity Code Description Project File Line Suppression State Error CS0120 An object reference is required for the non-static field, method, or property 'Form1.InitializeComponent()'
I tried to remove this line to avoid errors but it didn't fix the flickering.
I also tried adding listView1
, beginupdate
and endupdate
:
listView1.BeginUpdate();
foreach (ListViewItem li in listView1.Items)
{
if (li.SubItems[2].Text == lastUrl)
{
li.SubItems[0].Text = "Downloaded";
li.SubItems.Add("Color");
li.SubItems[0].ForeColor = Color.Green;
li.UseItemStyleForSubItems = false;
}
}
listView1.EndUpdate();
I tried this before adding the ListViewNF
method.
So far nothing helped with the flickering. Any suggestions?