954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Finding the object in an ArrayList

This is in VC++.NET. I dynamically create the number of buttons the user specifies. I add these buttons to an Arraylist. The buttons names goes from b1 ..bn where n is the max num of buttons. The user will provide me the button number and the text to be added to the button. How do I search the arraylist to find the button that the user wants? Thanks.

DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Lets say the buttons are b1 through b10. Will these be in order? If so. then this is rather easy. Your index values will be 0-9 or buttonN -1. So, when the user asks for a particular button, i.e. button 4 should have text ..., then you just need to take the input (4), subtract 1 and use this as the index for your array. Hope this helps.

sifuedition
Light Poster
25 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Thanks for the tip. That's exactly what I need. Don't know what I was thinking.

DotNetUser
Junior Poster in Training
69 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You