Hello.
I have a special label in my form, that should show in a tooltip some text. The label is declared as private class in the form (nested control), and should "see" the ToolTip control of the parent form.
Here is the code. Surely, I obtains errors here, because the constructor is called before the private control addition in the owner form control collection...
Edit: Is there a possibility do not pass the form1 or the toolTip control in constructor?
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
this.InitializeComponent();
FormLabel myFormLabel = new FormLabel("uraaaaa!");
this.Controls.Add(myFormLabel);
myFormLabel.Location = new Point(20, 20);
}
private class FormLabel : Label
{
public FormLabel(string toolTip) : base()
{
this.Text = toolTip.ToUpperInvariant();
(this.FindForm() as Form1).toolTip1.SetToolTip(this, toolTip);
}
}
}
}