Determining the currently pointed to item in a list
<p>I am working with lists. I have been able to determine the first and last position of items in my list. I am using <code>getPostion</code> and displaying item name through a <code>Label</code>. Three buttons in my form: <code>ShowFirstItem</code> <code>ShowNextItem</code>(not working) and <code>ShowLastItem</code> show the corresponding item in a label. I am having problems for my next item. I don't have a member that is holding the current <code>fruit_tree</code>. So I am not sure how to either add an <code>int</code> member or another <code>fruit_tree</code> member called <code>current</code>. How would I be able to find out next (item after first) and display result?</p>

<pre><code> public class ListForTrees
 {

        public fruit_trees GetNextTree()
            {
                current = 0;
                fruit_trees ft = first_tree;
                int i = 0;
                while (i != current)
                {
                    ft = ft.next_tree;
                    i++;

                }

                return ft;
            }

            }

            ListForTrees mainlist = new ListForTrees();     

            private void BtnGo_Click(object sender, EventArgs e)
            {
                fruit_trees[] ar_items = {   new fruit_trees("cherry", 48, 12.95, 3),
                                                 new fruit_trees("pine", 36, 9.95, 8),
                                                 new fruit_trees("oak", 60, 14.95, 2),
                                                 new fruit_trees("peach", 54, 19.95, 3),
                                                 new fruit_trees("pear", 36, 11.85, 2),
                                                 new fruit_trees("apple", 62, 13.45, 5)
                                             };   
                mainlist = new ListForTrees(ar_items);
                fruit_trees current = mainlist.first_tree;   

                while (current != null)
                {
                    TxtOutput.AppendText(current.ToString() + Environment.NewLine);
                    current = current.next_tree;
                }
            }


            private void ShowFirstItem_Click_1(object sender, EventArgs e)
            {
            // Show First Item
        labelSpecificTree.Text = mainlist.first_tree.GetTreeType;

            } 

            private void ShowLastItem_Click(object sender, EventArgs e)
            {
            //Show Last Item
        labelSpecificTree.Text = mainlist.last_tree.GetTreeType;
            }

        private void ShowNextItem_Click(object sender, EventArgs e)
            {
            //Show Next Item
 fruit_trees obj = mainlist.GetNextTree();

            if (obj == null)
            {
                labelSpecificTree.Text = "No more trees!";
            }
            else
            {
                mainlist.current++;
                labelSpecificTree.Text = obj.next_tree.GetTreeType.ToString();                
            }   
            }



        }
</code></pre>
