using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mod
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int c = 0;
private void button1_Click(object sender, EventArgs e)
{
TextBox txtRun = new TextBox();
txtRun.Name = "txtDynamic" + c++;
txtRun.Location = new System.Drawing.Point(20, 18 + (20 * c));
txtRun.Size = new System.Drawing.Size(200,15);
this.Controls.Add(txtRun);
}
private void button2_Click(object sender, EventArgs e)
{
List<string>tilelocation = List<string>();
tilelocation.Add(); //What goes in this method's arguments?
}
}
}
這是我的代碼。 Button1創建了一個理論上無限的文本框,但我希望將這些動態生成的文本框中的文本添加到列表中。如何才能做到這一點?
[編輯] 我怎樣才能將它們全部顯示在一個消息框中,每一行都在不同的行上?無法將動態生成的文本框的文本添加到列表(C#)
於是說, 「這是一個類型,而是像一個變量使用。」 (TextBox) – TheUnrealMegashark 2013-05-05 03:01:09
錯誤'System.Collections.Generic.List'是一個'類型',但用於'變量'\t < - 有確切的錯誤。 –
TheUnrealMegashark
2013-05-05 03:03:20
@ user2351094,我的壞,只是複製你的代碼,忘記了新的關鍵字。它應該是'新列表()' –
Habib
2013-05-05 03:05:13