G
Guest
How do I remove a item that's been selected from a listview?
I'm using Visual Basic 2005 express edition. Thanks
I'm using Visual Basic 2005 express edition. Thanks
Michael Nemtsev said:Hello Mike,
The same.
listView1.Items.Remove(listView1.SelectedItems[0]); - removes first item
MJ> Not Using a ListBox. Using a ListView
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
---Hello Mike,
The same.
listView1.Items.Remove(listView1.SelectedItems[0]); - removes first
item
MJ> Not Using a ListBox. Using a ListView
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>---Hello Mike,
Try ListBox.Items.*
MJ> How do I remove a item that's been selected from a listview?
MJ>
MJ> I'm using Visual Basic 2005 express edition. Thanks
MJ>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its
opponents
do not cease to be insipid." (c) Friedrich Nietzsche
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
Michael Nemtsev said:Hello Mike,
Yep. Did you look at MSDN for the listView1.SelectedItems method?
They use the same approach there
ListView.SelectedListViewItemCollection breakfast = this.ListView1.SelectedItems;
double price = 0.0;
foreach ( ListViewItem item in breakfast )
{
price += Double.Parse(item.SubItems[1].Text);
}
// Output the price to TextBox1.
TextBox1.Text = price.ToString();
MJ> What if I don't know the item by an index number? I want to be able
MJ> to remove the item that's been selected from the list. Will I need
MJ> to step through the items and check to see it it's been selected?
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>---Hello Mike,
The same.
listView1.Items.Remove(listView1.SelectedItems[0]); - removes first
item
MJ> Not Using a ListBox. Using a ListView
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>
Hello Mike,
Try ListBox.Items.*
MJ> How do I remove a item that's been selected from a listview?
MJ>
MJ> I'm using Visual Basic 2005 express edition. Thanks
MJ>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its
opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
---Hello Mike,
Yep. Did you look at MSDN for the listView1.SelectedItems method?
They use the same approach there
ListView.SelectedListViewItemCollection breakfast =
this.ListView1.SelectedItems;
double price = 0.0;
foreach ( ListViewItem item in breakfast )
{
price += Double.Parse(item.SubItems[1].Text);
}
// Output the price to TextBox1.
TextBox1.Text = price.ToString();
MJ> What if I don't know the item by an index number? I want to be
able
MJ> to remove the item that's been selected from the list. Will I
need
MJ> to step through the items and check to see it it's been selected?
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>---Hello Mike,
The same.
listView1.Items.Remove(listView1.SelectedItems[0]); - removes first
item
MJ> Not Using a ListBox. Using a ListView
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>
Hello Mike,
Try ListBox.Items.*
MJ> How do I remove a item that's been selected from a listview?
MJ>
MJ> I'm using Visual Basic 2005 express edition. Thanks
MJ>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its
opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its
opponents
do not cease to be insipid." (c) Friedrich Nietzsche
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche