467,905 Members | 1,875 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,905 developers. It's quick & easy.

remove a items that's been selected from a listview

How do I remove a item that's been selected from a listview?

I'm using Visual Basic 2005 express edition. Thanks

Jun 20 '06 #1
  • viewed: 1754
Share:
7 Replies
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
Jun 20 '06 #2
Not Using a ListBox. Using a ListView

"Michael Nemtsev" wrote:
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

Jun 20 '06 #3
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
Jun 20 '06 #4
What if I don't know the item by an index number? I want to be able to remove
the item that's been selected from the list. Will I need to step through the
items and check to see it it's been selected?

"Michael Nemtsev" wrote:
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

Jun 20 '06 #5
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
Jun 20 '06 #6
Yes I did, but was hoping for a better way. Thanks for your help.

"Michael Nemtsev" wrote:
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

Jun 20 '06 #7
Hello Mike,

Trully speaking it's a bit annoing :) but rather normal

MJ> Yes I did, but was hoping for a better way. Thanks for your help.
MJ>
MJ> "Michael Nemtsev" wrote:
MJ>
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

---
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
Jun 20 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by GTi | last post: by
7 posts views Thread by Visual Systems AB \(Martin Arvidsson\) | last post: by
3 posts views Thread by Julian Milano | last post: by
1 post views Thread by =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.