Hello to All
Can Somebody help me to solve one problem?
Here it is:
I've got the listview control, timer and data array str[*,*]
Array size is for example 40x2
I need to update data in listview each time when the timer ticks
I wrote this code:
private void Form1_Load(object sender, EventArgs e)
{
str = new string[40, 2];
for (int i = 0; i < 40; i++)
{
for (int j = 0; j < 2; j++)
{
str[i, j] = "a" + Convert.ToString(i) + " b" + Convert.ToString(j);
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
ListViewItem[] itmx = new ListViewItem[str.GetLength(0)];
for (int i = 0; i < str.GetLength(0); i++)
{
itmx[i] = new ListViewItem(i.ToString());
for (int j = 0; j < str.Length / str.GetLength(0); j++)
{
itmx[i].SubItems.Add(str[i, j]);
}
}
listView1.Items.Clear();
listView1.Items.AddRange(itmx);
}
But when i'm refresh listview, scrollbars moves, horizontal to left, and vertical to top, and listview control is blinking.
I try to use Virtual mode like here:
http://msdn.microsoft.com/ru-ru/library/system.windows.forms.listview.virtualmode.aspx
So, i solve problem with scrollbars, but listview is still blinking.
I understand, that I should update only those cells which have changed, but i don't know how.
I try to use this:
void Torrents_list_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
int x = e.ItemIndex;
for (int i = 0; i < Array_data_colums; i++)
{
if (Torrents_list.Items[x].SubItems[i].Text!=data[x,i])
{
Torrents_list.Items[x].SubItems[i] = data[x, i];
}
}
}
but it's does not work.
Please help me