当我点击.net表单中的鼠标点时,我需要自动(不是手动)生成文本框。例如:如果我在C#.net表单中单击鼠标点。然后我想生成特定形式的文本框。
tnxxxxxxxxxxxxxxxx
答案 0 :(得分:1)
看一下这个样本:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
TextBox tb = new TextBox();
tb.Location = new Point(e.X, e.Y);
tb.Width = 100;
this.Controls.Add(tb);
}
}
答案 1 :(得分:1)
你的意思是这样吗?
private void button1_Click(object sender, EventArgs e)
{
TextBox tb = new TextBox();
tb.Location = new Point(75, 75);
this.Controls.Add(tb);
}