Moshik

Moshik

  • NA
  • 5
  • 0

How to avoid blinking when refreshing listView

May 27 2009 4:00 AM
Hi, I am writing a tool which suppose to sample an external device every 1 second, retrieve data from it and display it on screen. I am using listView to do it but I have 1 problem: Each time I update the data, the screen blinks which is pretty annoying. This is my code: private void DisplayData() { try { ListViewItem itemDat; ssSampleData.lstViewSS.Clear(); SSData ssd; . . Some code... . . IDictionaryEnumerator myEnum = ssWiMAXHT.GetEnumerator(); while (myEnum.MoveNext()) { ssd.Name = myEnum.Key.ToString(); if (Array.IndexOf(MsSelectedParams, ssd.Name) >= 0 || ssd.Name.Equals("Sample number")) { ssd.Value = myEnum.Value.ToString(); string[] strItem = new string[2]; strItem[0] = ssd.Name; strItem[1] = ssd.Value; itemDat = new ListViewItem(strItem); ssSampleData.lstViewSS.Items.Add(itemDat); } } } ssSampleData.lstViewSS.Columns.Add("Name", -1, HorizontalAlignment.Left); ssSampleData.lstViewSS.Columns.Add("Value", -2, HorizontalAlignment.Left); ssSampleData.lstViewSS.Columns[0].Width = 200; ssSampleData.lstViewSS.Columns[1].Width = 400; } } catch (Exception ex) { TotalErrorRf++; Debug.WriteLine("DisplayData:: Exception time is" + FuncTime + ex.Message); } }

Answers (5)