473,396 Members | 2,013 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,396 software developers and data experts.

ArrayList Items

I have an ArrayList with 5 elements in it. I have a Next and a Prev button
on my form. I need to show the first element in a textbox when the form
opens. I need to move to the next element in the ArrayList when I click the
Next button and move to the previous element (if I am not on the first
element) when clicking the Prev button. Is there a way to keep track of
which element is in the textbox and then show either the next or previous
elements?
--
Robert Hill

Jun 20 '07 #1
1 2439
On Wed, 20 Jun 2007 15:29:56 -0700, Robert <rh******@hotmail.comwrote:
I have an ArrayList with 5 elements in it. I have a Next and a Prev
button
on my form. I need to show the first element in a textbox when the form
opens. I need to move to the next element in the ArrayList when I click
the
Next button and move to the previous element (if I am not on the first
element) when clicking the Prev button. Is there a way to keep track of
which element is in the textbox and then show either the next or previous
elements?
Yes.

Seriously though, your question doesn't have anything to do with
ArrayLists, and it has everything to do with how you handle the user
interface. You may want to consider using a more relevant subject in
future posts.

I will assume that the elements in your ArrayList either are strings, or
have a sensible ToString() implementation that you are using to set the
Text property of the TextBox. Then, all you need is an index that is
changed each time you click a button, and update the Text property
accordingly.

For example:

private void buttonNext_Click(object sender, EventArgs e)
{
_iobj = (_iobj + 1) % _list.Count;
textbox.Text = _list[iobj].ToString();
}

Where you have an "int _iobj" member in your class, initialized to 0 (the
first element in the list) and your ArrayList is named "_list", also in
your class.

I leave the implementation of buttonPrev_Click() to you as a homework
exercise.

Pete
Jun 20 '07 #2

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

Similar topics

6
by: Stephen | last post by:
Im trying to carry work out an else if clause in the below method but i'm having a lot of difficulty getting the correct code which allows me to check and see if an arraylist items has text in it...
2
by: Ralf B. | last post by:
Hi everybody I feel kind of dumb for not finding anything useful to point me in the right direction.. basically, I want to create a class with an Arraylist. I would like to add strings and...
3
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
3
by: Fred | last post by:
I'm trying to build a hashtable and a arraylist as object value I'm not able to retrieve stored object from the hashtable. Hashtable mp = new Hashtable(); // THE HASHTABLE ArrayList...
5
by: Tim | last post by:
Hi, I am creating a printing engine and I am cycling though my recordset. Each item gets added to an ArrayList. Once there are more items that will fit on the page I add the item ArrayList to a...
7
by: Dave | last post by:
Hi all, I have... using System.Collections; namespace MyApp.Templates { public class MyPage : System.Web.UI.Page { ArrayList MyArray = new ArrayList();
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
3
by: Stuart | last post by:
I am using Visual Basic 2005. I have created a two dimensional ArrayList named aSystem that is populated as follows:- aSystem.Add(New PickList(0, "Undefined")) aSystem.Add(New PickList(-1,...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
3
by: Justin | last post by:
Here's a quick rundown of what I'm doing. I'm filling an arraylist with data. Then I loop through a dataset and grab a field to perform a search on the arraylist. Every time I find a match I...
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: 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...
0
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...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.