リンクリストを使用しています。リストは、と呼ばれる複数行のテキストボックスに表示されるフォームの読み込み(サイズ、高さ、在庫、価格)で表示されtextBoxResults
ます。First
、、と呼ばれる3つのボタンがNext
ありLast
ます。命名規則は簡単です。ボタンFirst
クリックで最初のツリーが Next
表示され、、各ボタンクリックで最初から各アイテムが表示され 、ボタンをクリックするとLast
リストの最後のアイテムが表示されます。First
正常に動作しますがSecond
、最初の後に次の項目のみが表示され、あきらめて、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();
}
}
}