-1

For a project at school I need to create a program called Use Case Helper.

When I click somewhere in the windows form application, a textbox must appear. I don't know how I can achieve this, I think with a paint event, but i couldn't find anything.

Could someone point me in the right direction?

Jules
  • 546
  • 2
  • 11
  • 36

2 Answers2

2
    private void Form1_MouseUp(object sender, MouseEventArgs e)
    {
        TextBox tb = new TextBox();
        tb.Text = "Sample Stuff";

        tb.Location = e.Location;

        this.Controls.Add(tb);
    }

This will add a textbox wherever you click.

colsw
  • 3,216
  • 1
  • 14
  • 28
0

You should examine OnClick event on your Form or Panel. Then you should get x and y parameters and, finally, use method panel1.Controls.Add(yourTextBox); But seriously, this is googleable question, so, please, avoid asking such on StackOverflow.

insomnium_
  • 1,800
  • 4
  • 23
  • 39
  • Thank you for your answer, I couldn't find the solution on google though – Jules Feb 12 '15 at 11:34
  • 1
    Seriously? Just a quick search: How to get mouse position on click c#: http://stackoverflow.com/questions/7055211/how-to-get-the-position-of-a-click How to add control on panel: http://stackoverflow.com/questions/9763228/how-to-add-user-control-to-panel – insomnium_ Feb 12 '15 at 11:35