Change ListView SubItem value
-
Hi All, I am using a ListView Control to display clients connected to a server. The ListView is set to View.Details and has three columns, 1) Client ID, 2) Client Name 3) Connection Status. What I would like to do is update the 'Connection Status' SubItem to display whether they are connected or disconnected. Can anyone shed any light, thanks. Regards
Web design and hosting http://www.kayess.com.au
-
Hi All, I am using a ListView Control to display clients connected to a server. The ListView is set to View.Details and has three columns, 1) Client ID, 2) Client Name 3) Connection Status. What I would like to do is update the 'Connection Status' SubItem to display whether they are connected or disconnected. Can anyone shed any light, thanks. Regards
Web design and hosting http://www.kayess.com.au
-
Sorry, still can't see how I can do it.
Web design and hosting http://www.kayess.com.au
-
Here is what I am trying to do, from what I've read:
string search = "x1"; string status = (ConnectionStatus) ? "Connected" : "Disconnected"; int i_row = myListView.Items.IndexOfKey(search); myListView.SelectedItems[i_row].SubItems[3].Text = status;
However the i_row value returned is always -1Web design and hosting http://www.kayess.com.au
-
Here is what I am trying to do, from what I've read:
string search = "x1"; string status = (ConnectionStatus) ? "Connected" : "Disconnected"; int i_row = myListView.Items.IndexOfKey(search); myListView.SelectedItems[i_row].SubItems[3].Text = status;
However the i_row value returned is always -1Web design and hosting http://www.kayess.com.au
-
Yes, I have updated from my previous post the ListView items look like this Col 1, Row 1 = Client ID (eg 23) Col 2, Row 1 = Client Name (eg Steve) Col 3, Row 1 = Connection Status (Connected / Disconnected) This is the subitem I want to change programatically. Col 4, Row 1 = Identifier (in this case 'x1') The next Row Identifier would be x2 and so on... Thanks
"You don't scare me Selene."-Tanis "We'll have to work on that."-Selene (Underworld Evolution)
-
Yes, I have updated from my previous post the ListView items look like this Col 1, Row 1 = Client ID (eg 23) Col 2, Row 1 = Client Name (eg Steve) Col 3, Row 1 = Connection Status (Connected / Disconnected) This is the subitem I want to change programatically. Col 4, Row 1 = Identifier (in this case 'x1') The next Row Identifier would be x2 and so on... Thanks
"You don't scare me Selene."-Tanis "We'll have to work on that."-Selene (Underworld Evolution)
It appears your searching your List View Items instead of each item's SubItem. Try something along the lines of this.
//If i_row is not needed for anything else delete the next line
int i_row;
string search = "x1";
string status = (ConnectionStatus) ? "Connected" : "Disconnected";
for (int i = 0; i < myListView.Items.Count; i++)
{
if (!(myListView.Items[i].SubItems.IndexOfKey(search) == -1))
{
//If i_row is not needed for anything else delete the next line
i_row = i;
myListView.Items[i].SubItems[3].Text = status;
break;
}
}modified on Friday, January 18, 2008 5:53:11 AM
-
It appears your searching your List View Items instead of each item's SubItem. Try something along the lines of this.
//If i_row is not needed for anything else delete the next line
int i_row;
string search = "x1";
string status = (ConnectionStatus) ? "Connected" : "Disconnected";
for (int i = 0; i < myListView.Items.Count; i++)
{
if (!(myListView.Items[i].SubItems.IndexOfKey(search) == -1))
{
//If i_row is not needed for anything else delete the next line
i_row = i;
myListView.Items[i].SubItems[3].Text = status;
break;
}
}modified on Friday, January 18, 2008 5:53:11 AM
Hi, Thanks, but that didn't work either. However I did find a solution
string search = "x1"; string status = (ConnectionStatus) ? "Connected" : "Disconnected"; for (int i = 0; i < myListView.Items.Count; i++) { { ListViewItem item = myListView.Items; if(item.SubItems[4] == search) items.SubItems[3].Text = status }
Thanks all for your suggestions."You don't scare me Selene."-Tanis "We'll have to work on that."-Selene (Underworld Evolution)