|
-
February 18th, 2004, 10:56 AM
#1
Byte to Item
foreach (byte key in keys)
{
listView1.Items.Remove(????);
}
Remove require an Item, how do I go from a key byte to an Item ?
-
February 18th, 2004, 12:06 PM
#2
Hi Jedhi,
if I remember some of your earlier posts correctly, you are storing 'key' as a subitem in a ListViewItem.
In which case it is not a simple case of converting 'key' to ListViewItem.
Maybe the easiest way is to create a Hashtable of 'key' against its containing ListViewItem and then you can use:
listView1.Items.Remove(lookup [key]);
-
February 18th, 2004, 12:32 PM
#3
Thanks !
Puttet this as a member to my IDictionary Interface.
Object lookup(Object key);
But how do I make lookup understandble for the compiler !
Last edited by Jedhi; February 18th, 2004 at 12:59 PM.
-
February 18th, 2004, 02:49 PM
#4
Not sure what you mean!
What I mean (based on your previous posts):
Code:
Hashtable lookup = new Hashtable();
ListViewItem item = new ListViewItem(new string[] {key, value});
lookup.Add(key, item);
listView1.Items.Add(item);
etc.
foreach (byte key in keys)
{
listView1.Items.Remove(lookup[key]);
}
-
February 18th, 2004, 03:26 PM
#5
I thought that lookup was some fancy word. But I can see now it is the name of the hashtable... LOL.
I've already done as you described, but I get an error CS1502 + CS1503 telling that Argument '1': cannot convert from 'object' to 'System.Windows.Forms.ListViewItem'
The Remove in IDictionary looks like this:
void Remove(Object key);
// should it be void Remove(byte key) instead ???
-
February 23rd, 2004, 02:47 AM
#6
It's probably complaining about
Code:
listView1.Items.Remove(lookup[key]);
(maybe) it should be:
Code:
listView1.Items.Remove((ListViewItem)lookup[key]);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|