Hi,
How do I loop through listbox items?
Thanks,
yue 7 66778
This will serve.
foreach(object o in listBox1.Items)
Sam
"yue" <yu*@mail.com> wrote in message
news:0c****************************@phx.gbl... Hi,
How do I loop through listbox items?
Thanks,
yue
Hi,
That did not work also.
yue -----Original Message----- try:
foreach (string s in listBox1.Items)
"yue" <yu*@hotmail.com> wrote in message news:4d****************************@phx.gbl... Hi Sam, i have done this but cant get the row values.
Please help,
thanks,
yue >-----Original Message----- >This will serve. > > foreach(object o in listBox1.Items) > >Sam > > >"yue" <yu*@mail.com> wrote in message >news:0c****************************@phx.gbl... >> Hi, >> >> How do I loop through listbox items? >> >> Thanks, >> >> yue > > >. >
.
ListBox items accept objects of any type as elements. Find where the
elements are being added, and use that class in the foreach. For instance,
if you do this
listBox1.Items.Add(new MyCustomClass("Hi", 3, true));
then you would do this to get the values
foreach (MyCustomClass item in listBox1.Items) {
}
Chris
"yue" <yu*@mail.com> wrote in message
news:0c****************************@phx.gbl... Hi,
How do I loop through listbox items?
Thanks,
yue
Chris,
This is good if you use the add method of the listbox.
I set the listbox Datasource on a filtered DataTable.
This is why i need to loop through the listbox and get the
elements.
Is there no easy way to do this? This is so frustrating to
me...
yue -----Original Message----- ListBox items accept objects of any type as elements.
Find where theelements are being added, and use that class in the
foreach. For instance,if you do this
listBox1.Items.Add(new MyCustomClass("Hi", 3, true));
then you would do this to get the values
foreach (MyCustomClass item in listBox1.Items) { }
Chris
"yue" <yu*@mail.com> wrote in message news:0c****************************@phx.gbl... Hi,
How do I loop through listbox items?
Thanks,
yue
.
In this case, you ought to loop through the datasource instead of the list
box's collection. For a DataTable, this is
foreach (DataRow row in dataTable1.Rows) {}
It ought to be similar for a DataView.
Chris
"yue" <yu*@hotmail.com> wrote in message
news:4e****************************@phx.gbl... Chris, This is good if you use the add method of the listbox. I set the listbox Datasource on a filtered DataTable. This is why i need to loop through the listbox and get the elements.
Is there no easy way to do this? This is so frustrating to me...
yue-----Original Message----- ListBox items accept objects of any type as elements. Find where theelements are being added, and use that class in the foreach. For instance,if you do this
listBox1.Items.Add(new MyCustomClass("Hi", 3, true));
then you would do this to get the values
foreach (MyCustomClass item in listBox1.Items) { }
Chris
"yue" <yu*@mail.com> wrote in message news:0c****************************@phx.gbl... Hi,
How do I loop through listbox items?
Thanks,
yue
.
Chris,
Thank You for all your help.
I will try this.
yue -----Original Message----- In this case, you ought to loop through the datasource
instead of the listbox's collection. For a DataTable, this is
foreach (DataRow row in dataTable1.Rows) {}
It ought to be similar for a DataView.
Chris
"yue" <yu*@hotmail.com> wrote in message news:4e****************************@phx.gbl... Chris, This is good if you use the add method of the listbox. I set the listbox Datasource on a filtered DataTable. This is why i need to loop through the listbox and get
the elements.
Is there no easy way to do this? This is so frustrating
to me...
yue >-----Original Message----- >ListBox items accept objects of any type as elements. Find where the >elements are being added, and use that class in the foreach. For instance, >if you do this > >listBox1.Items.Add(new MyCustomClass("Hi", 3, true)); > >then you would do this to get the values > >foreach (MyCustomClass item in listBox1.Items) { >} > >Chris > >"yue" <yu*@mail.com> wrote in message >news:0c****************************@phx.gbl... >> Hi, >> >> How do I loop through listbox items? >> >> Thanks, >> >> yue > > >. >
.
On Wed, 30 Jul 2003 08:22:31 -0700, in the
microsoft.public.dotnet.languages.csharp group, yue said... How do I loop through listbox items?
Items is a property of a listBox containing a collection. If you follow
the links from ListBox Class to ListBox Members to Items (inherited from
ListControl) to ListControl.Items Property you will find one example of
how to iterate through the list.
In addition, follow through from CollectionBaseClass, CollectionBase
Members to GetEnumerator which describes also MoveNext, Current and
Reset.
So essentially you have choices of for, foreach and GetEnumerator
approaches to do what you want to do.
Gerald This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christina |
last post by:
I have a post-form that holds a listbox with mulitple selected items. When
the form is posted to the server ASP file, I want to loop through the
selected items, to insert each of them into a table....
|
by: amber |
last post by:
Hello.
Can someone tell me what I may be doing wrong here?
I'm using the code (lboxRP is a listbox):
Dim newRPindex As Integer
newRPindex = Me.lboxRP.FindString(RP)...
|
by: Ryan Ternier |
last post by:
Thanks for the previous help guys!
I got my list box issue working, but now i'm trying to loop through all the
items in my page.
I want to find each listbox, once I do i strip the ID down to...
|
by: Janaka |
last post by:
Help! I have two ListBox controls on my web form. The first one gets
populated on entry with values from the DB. I then use JavaScript to copy
options from this ListBox to my second one. (I...
|
by: Dave |
last post by:
Hi all,
I have a listbox that is complex bound by an arraylist. The problem is that
when I delete an object from the arraylist, the listbox does not reflect
those changes. I tried refreshing...
|
by: Jeff |
last post by:
....another beginner question - using visual web 2005 with VB
I have 20 labels - lbl1 through lbl20
I have a listbox containing values 1 through 20
I need to make label 1 through the...
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
I have a ListBox server control named "lb_dates" with a SelectionMode of
"Multiple". The user can select multiple dates from the listbox.
I have ObjectDataSource named "ods_rfq" with a...
|
by: OuTCasT |
last post by:
I have a listbox on my form that has items that the user has chosen, i need to loop through the listbox and get the values and insert them into a sql table.
Can anyone hlp?
|
by: OuTCasT |
last post by:
I have bound a listbox with a dataTable
Now i want to move the values from the listbox to another listbox.
i have changed the selectionMode of the listbox to multiple.
So they choose multiple...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |