开发者

need to generate text box automatically when i'm click on the mouse point in the .net form

i gust need to generate text box automatically(not manually ) when i'm click on the mouse point in the .net f开发者_如何学Corm. ex : if i click in mouse point in C#.net form. then i want to generate text box for particular form.

tnxxxxxxxxxxxxxxxx


Take a look at this sample:

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);
    }
}


Do you mean something like this?

private void button1_Click(object sender, EventArgs e)
{
    TextBox tb = new TextBox();
    tb.Location = new Point(75, 75);
    this.Controls.Add(tb);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜