1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
private delegate void AddSubItemDelegate(string s, ListViewItem myItem);
private void AddSubItem(string s, ListViewItem myItem)
{
if (listView1.InvokeRequired)
{
// Pass the same function to BeginInvoke,
// but the call would come on the correct
// thread and InvokeRequired will be false.
listView1.BeginInvoke(new AddSubItemDelegate(AddSubItem), new object[] { s }, new object[] { myItem });
return;
}
myItem.SubItems.Add(s);
return ;
// ........ code dans le thread
/// now add the data
ListViewItem lvItem = new ListViewItem();
while (reader.Read() == true)
{
lvItem = AddItem(reader.GetValue(0).ToString());
for (int i = 1; i < nCount; i++)
{
AddSubItem(reader.GetValue(i).ToString(), lvItem);
}
} |
Partager