First of all, I'd like to have an array, or a list (not sure of the difference), to store the ListViewItems.
This way, instead of making a new item called 'item', I could make a new item stored in Array[5] so it can easily be deleted later using Array[5].Remove(), or something similar.
public delegate void AddListViewItemDelegate(ListViewItem lv);
public void AddListViewItem(ListViewItem lv)
{
if (hClientList.InvokeRequired)
Invoke(new AddListViewItemDelegate(AddListViewItem), new object[] { lv });
else
hClientList.Items.Add(lv);
}
private void hServerMainWindow_Load(object sender, EventArgs e)
{
Thread NetworkThread = new Thread(new ThreadStart(NetThread));
NetworkThread.IsBackground = true;
NetworkThread.Start();
}
public void NetThread()
{
//Code run when I want to create a new item (iClient contains index in array I want to store position)
ListViewItem item = new ListViewItem("Client " + iClient); //Instead of 'item' I want it to be stored to an array at index iClient
AddListViewItem(item);
//code run when I want to delete an item
//Remove an item using an integer corresponding to an index of the array, such as iClient again
}
Pseudo-code:
Create ListViewItemArray[100]
Create ListViewItem in array at [x], AND display it in my ListView
Delete ListViewItem from array [x], AND remove it from the ListView
Hopefully I am being clear enough.

New Topic/Question
Reply




MultiQuote






|