472,967 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,967 software developers and data experts.

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
7 1988
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: GTi | last post by:
I have a listview that with selected items. But I want to "reselect" items after a refresh. Each items have a uniqe value in the Tag object. After a refresh some new items may be added or removed...
7
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I'v been struggeling with removing selected items from a listview. Anyone that can give me a piece of code that does this? I am a newbee to this C# and cant figure it out.... Regards...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
2
by: Mamatha | last post by:
Hi I have an application with listview.When i click on one button the data will be displayed like this in the listview: colA colB colC ----- ----- ------...
7
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname,...
3
by: Julian Milano | last post by:
I'm using the following code to act on only the selected items in a listview. The items are selected via checkboxes: Dim indexes As ListView.SelectedIndexCollection = .SelectedIndices For Each i...
1
by: dvestal | last post by:
I have a ListView with checkboxes. I want to remove items when the checkboxes are unchecked, but to do so yields an ArgumentOutOfRangeException. Is there an easy way to get around this? A...
1
by: Garudzo | last post by:
Hi all I am developning a small application in MS Access 2003 on a windows XP platform. I am using windows treeview and Listview controls. I have discovered that I can do a multi select of...
1
by: =?Utf-8?B?TWFyayBDb2xsYXJk?= | last post by:
Hello I've added a listview to my WinForms C# 2.0 application. The listview is displayed in Details view and has the FullRowSelect property set to true. I'm using the listview control like a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.