How do I check how MANY items a listbox has?

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2008
Posts: 45
Reputation: papuccino1 is an unknown quantity at this point 
Solved Threads: 1
papuccino1's Avatar
papuccino1 papuccino1 is offline Offline
Light Poster

How do I check how MANY items a listbox has?

 
0
  #1
Sep 26th, 2008
For instance in a "For" loop:

  1. for(int i = 0;i<=listBox1.

What could I place after the "." at the end to check so it doesn't keep on working after the number of items?
My very first baby boy, coming December 2008. :D
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 58
Reputation: vckicks is an unknown quantity at this point 
Solved Threads: 9
vckicks vckicks is offline Offline
Junior Poster in Training

Re: How do I check how MANY items a listbox has?

 
1
  #2
Sep 27th, 2008
try something like this:

for (int i = 0; i < listBox1.Items.Count; i++)

make sure it's i < and not i <= since you are starting with index 0.

Good luck
Visual C# Kicks - Free C# code resources and articles.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 45
Reputation: papuccino1 is an unknown quantity at this point 
Solved Threads: 1
papuccino1's Avatar
papuccino1 papuccino1 is offline Offline
Light Poster

Re: How do I check how MANY items a listbox has?

 
0
  #3
Sep 27th, 2008
Cool, thank you for your tip. I'll try it out later tonight.
My very first baby boy, coming December 2008. :D
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: How do I check how MANY items a listbox has?

 
0
  #4
Sep 29th, 2008
Read the intellisense of the property, it will help you. I think you did not do some efforts... hehehehe no offense meant, that's for your own good. if problem persist consult your f***n brilliant mind, I know you have lots of guts!!!

regards.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 783 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC