Get info from a listview and pass to a method ?
-
Hi, I'm writing a process manager as my first real 'project,' I've got all the info into a listview (including the pid) and a kill method that works if you manually enter the pid but how would I go about extracting the pid and passing it to the method based on which row has been clicked ? TIA. -- modified at 3:59 Sunday 26th February, 2006
-
Hi, I'm writing a process manager as my first real 'project,' I've got all the info into a listview (including the pid) and a kill method that works if you manually enter the pid but how would I go about extracting the pid and passing it to the method based on which row has been clicked ? TIA. -- modified at 3:59 Sunday 26th February, 2006
-
if(listBox1.SelectedIndex >= 0) { string a = (string)listBox1.SelectedItem; // do you stuff here to extract the pid from string a KillDaProcess(pid); } or use SelectedItems and loop thru the items if you allow user to multi-select
-
Gah, I meant listview rather than box, sorry. Though I tried something like that initially, but it just kept returning "System.Windows.Form.ListView + SelectedListViewItemCollection" and nothing much to do with whats actually in the table.
-
Gah, I meant listview rather than box, sorry. Though I tried something like that initially, but it just kept returning "System.Windows.Form.ListView + SelectedListViewItemCollection" and nothing much to do with whats actually in the table.
if you use listview, there is a Tag property that let you... hmm.. tag an object to an Item or SubItem. You can just tag the pid string to Item's Tag, or you can tag a class containing the pid string + other stuffs to the tag. So once you are able to get the SelectedItem, just take the object from Tag and that will be your pid. Array array = listView1.SelectedItems; if(array.Count>0) { for(int i=0; i
-
if you use listview, there is a Tag property that let you... hmm.. tag an object to an Item or SubItem. You can just tag the pid string to Item's Tag, or you can tag a class containing the pid string + other stuffs to the tag. So once you are able to get the SelectedItem, just take the object from Tag and that will be your pid. Array array = listView1.SelectedItems; if(array.Count>0) { for(int i=0; i