Thursday, 5 September 2013

Insert Label at Cursor Location

Insert Label at Cursor Location

I want to a label at the cursor position whenever the user clicks the
form. From the answer in this question: Getting mouse position in c#
I have used
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
Label lbl = new Label();
lbl.Location = Cursor.Position;
lbl.Visible = true;
this.Controls.Add(lbl);
}
but when i run the program and click the form, nothing happens.
Pls what did i do wrong?

No comments:

Post a Comment