473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Listbox collection

Hello All,

I want to go through each item in a Listbox collection. How will I do this?

I was looking for ListBoxItem but nothing is available?

Any suggestions please?

Thanks
Anand Ganesh
Aug 20 '07 #1
4 2137
On Aug 20, 2:57 pm, "Anand Ganesh" <agan...@nobel-systems.comwrote:
Hello All,

I want to go through each item in a Listbox collection. How will I do this?

I was looking for ListBoxItem but nothing is available?

Any suggestions please?

Thanks
Anand Ganesh
It's ListBox.Items.

Aug 20 '07 #2
Anand,

The listbox exposes the Items property, which returns a type of
ListBox.ObjectCollection. This type implements IEnumerable, which means you
can use in a for each statement.

The ListBox.ObjectCollection class holds instances of type object
though. The ListBox accesses the property indicated in the DisplayMember
property of the ListBox, or calls ToString on the object, if the
DisplayMember property does not have a value.

Also, if the list box is data-bound, then the Items property will have
no items in it, and you will have to access the listbox's data source
directly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Anand Ganesh" <ag*****@nobel-systems.comwrote in message
news:OQ**************@TK2MSFTNGP02.phx.gbl...
Hello All,

I want to go through each item in a Listbox collection. How will I do
this?

I was looking for ListBoxItem but nothing is available?

Any suggestions please?

Thanks
Anand Ganesh

Aug 20 '07 #3
private void button1_Click(object sender, EventArgs e)
{
string s = "";
for (int i = 1; i <= lvwMyListView.Items.Count - 1; i++)
{
s = s + lvwMyListView.Items[i].Text + char.Parse("\n");
}
MessageBox.Show( s);

}
Aug 20 '07 #4
Hello All,

Thank you very much for the quick reply and clarification.

Regards
Anand
"Anand Ganesh" <ag*****@nobel-systems.comwrote in message
news:OQ**************@TK2MSFTNGP02.phx.gbl...
Hello All,

I want to go through each item in a Listbox collection. How will I do
this?

I was looking for ListBoxItem but nothing is available?

Any suggestions please?

Thanks
Anand Ganesh

Aug 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Maria | last post by:
How can I display the items in a collection in a listbox? Then, what is the code to remove an item from the collection when the item is selected in the listbox ? Thanks for all help!! Maria
3
by: Prasad | last post by:
Hey All, I am having a little trouble with the ListBox's Items collection property. I am populating the ListBox with data contained in an SQL table using SQLDataAdapter and DataSet. I have...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
1
by: Josema | last post by:
Hi, My problem is the next one (in a windows application): - I have a class derived from collectionbase to fill with persons object (id, name) from database. - I have a ListBox wich datasource...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
3
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
0
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
5
by: markr1000 | last post by:
I must have looked searched in 500+ places that showed up in Google searchs, but not one has an example of what I want to do. I have a Listbox on a User Control because I want to control the...
3
by: caracolito1975 | last post by:
Hi to every one!!!! For some time now I'm programing in .NET and I have a question in using ListBox I need to databind a collection to a ListBox. My code is something like this: using...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.