日期:2014-05-18 浏览次数:21254 次
namespace MyApplication
{
public partial class Form1 : Form
{
delegate void ShowText();
TextBox textBox1 = new TextBox();
Button button1 = new Button();
public Form1()
{
textBox1.Text = "出题的人很无聊...";
textBox1.Location = new Point((Width - textBox1.Width) / 3, (Height - textBox1.Height) / 3);
textBox1.Parent = this;
button1.Text = "button1";
button1.Location = new Point(textBox1.Left + textBox1.Width + 8, textBox1.Top);
button1.Click += new EventHandler(button1_Click);
button1.Parent = this;
}
void button1_Click(Object sender, EventArgs e)
{
Invoke(new ShowText(DoShowText));
}
void DoShowText()
{
MessageBox.Show(textBox1.Text);
}
}
}
------解决方案--------------------
手写比较强悍