i have a form in which i add account info"name gender country etc.." i declared list of my new class "account"..and i want to implement a "next" button..
if im displaying a spesific account info. i want to display next one on the form..
how do i know in what item in the list i am?? to move to the next item and display its info??
Loading
Suthish NairPosted Mar 3, 2011, 11:57 AM
fawzan mohamedPosted Mar 3, 2011, 2:06 AM
VulpesPosted Mar 2, 2011, 8:58 AM
You can then increment it when the Next button is pressed.
If the end of the list has then been reached, you could wrap around to the first item, by setting the current index to 0.
Some 'rough and ready' code:
private int currentIndex = -1; // impossible starting value
private void btnNext_Click(object sender, EventArgs e)
{
currentIndex++; // will be zero, when button first clicked
if (currentIndex == list.Count) currentIndex = 0;
// code to display current record
}