我正在使用链接列表。该列表是在名为textBoxResults
. 我有三个按钮叫做First
,Next
和Last
。命名约定很简单,按钮First
单击显示第一个树, Next
在第一次单击按钮后显示每个项目, Last
按钮显示列表中的最后一个项目。First
工作正常,但Second
只在 first 之后显示以下项目并放弃,Last
显示奇怪的结果WindowsFormsApplication1.Form1+Fruit Trees
。如何通过单击按钮根据其位置显示正确的树名称?
代码
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();
}
}
}