-
March 28th, 2011, 06:07 PM
#1
[RESOLVED] diminishing list
Thanks in advance.
I am having issues figuring out how to implement a diminishing list (that's what I am calling it).
I want to ready a list of names from a table into something (an array, listview,etc) and then be able to populate a textbox one name at a time so that a name can be assigned something by a button click, and then it will load the next name in the list. At the end of the list it will check and reload a list. The list is of unknown length.
I am not sure how to do this type of function.
-
March 28th, 2011, 07:30 PM
#2
Re: diminishing list
Maybe you want it to make you a cup of coffee?
Code:
so that a name can be assigned something by a button click,
-
March 28th, 2011, 08:37 PM
#3
Re: diminishing list
What have you got so far?
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
March 29th, 2011, 09:33 AM
#4
Re: diminishing list
This is my pseudo code
What do you think
Code:
public int i = 0;
read data into an array
get the number of objects in array and set to i
private void button_click()
{
while (number of objects in array != i+1)
{
textbox1.text = stringArray[i].toString();
}
i++
}
its kinda rough because I am not sure how to go about this.
-
March 29th, 2011, 09:54 AM
#5
Re: diminishing list
The textbox will overwrite so fast the only entry you'll be able to read is the last one.
If you need to cycle through the array entries on each button click, store the current index to the array as a class field or property.
When you click the button, use the current index to access the array and set the textbox text. Then increment the current index (for next time).
-
April 1st, 2011, 11:49 AM
#6
Re: diminishing list
Figured it out
This is out I implemented the solution
void Button_Click(object sender, EventArgs e)
{
//do stuff
ListProgression(); //increments names by one
}
private void ListProgression()
{
string[] name ={ "Mark", "Beth", "Alex", "Spade", "John", "Bethany", "Caleb", "Connor", "Mike", "Ryan", "Justin", "Amy", "James" };
int NumberofNames = name.Length;
if (i != NumberofNames)
{
this.label3.Text = name[i];
i++;
}
else
{
MessageBox.Show("end of list");
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|