【发布时间】:2021-08-02 03:22:57
【问题描述】:
Char[] mychars = { ' ' };
string myText = "Hello how are you";
string[] names = myText.Split(mychars);
int idef=0;
foreach(string x in names)
{
Button b = new Button
{
Width = 100,
Name = "b" + idef,
Text = x,
Location = new Point(centerLine.Location.X + idef * 100, centerLine.Location.Y),
};
b.Click += (sender1, e1) =>
{
textBox1.Text += ((Button)sender1).Text;
};
this.Controls.Add(b);
idef++;
}
b0.Text = "change";
b0 是我创建的按钮,但它在当前上下文中不存在,我如何将其引用到自身?我在 Visual Studio 工作,它是一个 Forms 应用程序。
【问题讨论】:
-
嘿,请添加更多关于上下文的信息。你的问题无助于说明情况。修复标签并简要描述您正在使用的平台,然后有人投反对票并使您失去动力。谢谢。