How I added items to the server from ListView:
serverName.opGroup.OPCItems.AddItem("itemName", listView.Items.Count);
This runs each time I click the button to add a new item to ListView.
Now when I try to update a listView with DataChange event
public void StructOPCServer_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues, ref Array Qualities, ref Array TimeStamps){
foreach(int item in ClientHandles){
listViewName.Items[item-1].SubItems[1].Text = ItemValues.GetValue(item).ToString();
}
}
ClientHandles get mixed up somehow although I haven't changed the position of items in my listview.
For exmaple:
ListViewItem[0] should be ClientHandle = 1
ListViewItem[1] should be ClientHandle = 2
ListViewItem[3] should be ClientHandle = 3
Instead I get for exmaple:
ListViewItem[0] should be ClientHandle = 3
ListViewItem[1] should be ClientHandle = 1
ListViewItem[3] should be ClientHandle = 2
and each time I run the app and do the same process (adding same items in same order) each time ClientHandle mixes up a different way.
So I was hoping if there is solution to this or can I somehow access items name withing DataChange event (that I have added in AddItem() method). So what way I could compare if a new value ive got is from the item with same name like the one I got in ListView.
1 Guest(s)