Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8981833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:25:58+00:00 2026-06-15T20:25:58+00:00

I am working with a link list. The list is brought up on the

  • 0

I am working with a link list. The list is brought up on the form load (size, height, stock, price) displayed in a multiline textbox called textBoxResults. I have three button called First, Next and Last. Naming convention is straightforward, button First click displays first tree, Next, displays each item after first through each button click and Last button shows the last item on list. First works fine but Second only shows the following item after first and gives up, Last displays weird result WindowsFormsApplication1.Form1+Fruit Trees. How can I display the proper tree name according to its position through the button clicks?

Code

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        public class ListOfTrees
        {
            private int size;

            public ListOfTrees()
            {
                size = 0;
            }

            public int Count
            {
                get { return size; }
            }

            public FruitTrees First;
            public FruitTrees Last;




        }


        public void ShowTrees()
        {

        }



        public void Current_Tree()
        {
            labelSpecificTree.Text = Trees.First.Type.ToString();
        }

        private void Form1_Load_1(object sender, EventArgs e)
        {

        }

        private void buttonFirst_Click(object sender, EventArgs e)
        {
            Current_Tree();
        }

        private void buttonNext_Click(object sender, EventArgs e)
        {
            Current = Trees.First;
            labelSpecificTree.Text = Current.Next.Type.ToString();
        }

        private void buttonLast_Click(object sender, EventArgs e)
        {
            Current = Trees.Last;
            labelSpecificTree.Text = Trees.Last.ToString();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:26:00+00:00Added an answer on June 15, 2026 at 8:26 pm

    Several problems in your code (see the comments for corrections):

            public int Add(FruitTrees NewItem)
            {
                FruitTrees Sample = new FruitTrees();
                Sample = NewItem;
                Sample.Next = First;
                First = Sample;
                //Last = First.Next;
                // Since Add is an  operation that prepends to the list - only update
                // Last for the first time:
                if (Last == null){
                  Last = First;
                }
    
                return size++;
            }
    

    Secondly in your Next method:

        private void buttonNext_Click(object sender, EventArgs e)
        {
            // In order to advance you need to take into account the current position
            // and not set it to first...
            //Current = Trees.First;
            Current = Current.Next != null ? Current.Next : Current;
            labelSpecificTree.Text = Current.Type.ToString();
        }
    

    And in the “last” method:

        private void buttonLast_Click(object sender, EventArgs e)
        {
            Current = Trees.Last;
            // show the data, not the name of the Type
            labelSpecificTree.Text = Current.Type.ToString();
        }
    

    And of course the current method is broken, also…

        public void Current_Tree()
        {
            Current = Trees.First;
            labelSpecificTree.Text = Current.Type.ToString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with a link list. The list has items based on inserted
I am working with a link list. I have set my constructor to take
I am working with a link list. My constructor takes arrays with items in
The app I'm working on has a physician look-up list. It's a simple form
I'm working through an iPhone tutorial ( link text and it has me put
As we are working locally so our service link is: http://localhost:8012/webservice.asmx When we deploy
I'm working on some code to insert a link to a dupe in the
I was working on a site recently and we adding an RSS link to
I'm working on a website which has advert banners which link to external pages.
I'm working on the links at the very top - when a link is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.