I need to add a text line in a specified point of a windows form. In this form I draw something and I would like to describe the draw exactly where it is pointed.

Is there a way to add a tooltip in a specified point of a Form?

For example something like:

Point pt = new Point (490,567);
ToolTip tt = new ToolTip();
pt.ToolTip=tt;

Other ways I've tried:

1- Label class, but when I add the control with Controls.Add(label) the system restart execution of the draw, I don't know why.
2- TextBox class, but execution become quite slow when the program add the textbox.

If you have some suggestions also for these 2 other ways it will be so appreciated :)

thanks

Try it this way:

private void button1_Click(object sender, EventArgs e)
        {
            Label l = new Label();
            l.Location = new Point(100, 100);
            l.Text = "This is a text";
            this.Controls.Add(l);
        }

Thanks, I've tried this solution and I think is the best one but as I said it has a strange behavior.

I have to draw some shapes and when the shape is drawn I have to put a comment in the point where it starts. The strange behavior of labels is that when the comment is added, the program restart execution of the drawing.. anyone knows why does it happen?

Thanks

where are you writing the code of adding text to the label?

where are you writing the code of adding text to the label?

I've put the code during the drawing..but the label wait for the drawing then put the label and restart execution..

While you are busy drawing some shapes, why not use that opportunity to also draw some strings?
http://msdn.microsoft.com/en-us/library/76c5db29.aspx

That's a great solution thanks ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.