If the application is using one ToolTip control for many Windows Forms controls, then you can disassociate a particular Windows Forms control from the ToolTip by calling ToolTip.SetToolTip and passing a reference to the control and an empty string for the ToolTip caption. When an empty string is passed for the ToolTip caption, the SetToolTip method removes the reference to the Windows Forms control from within the ToolTip's internal HashTable. Note that you can also call the ToolTip.RemoveAll to remove all ToolTip text and disassociate the ToolTip control from all Windows Forms controls.
If the application is not associating multiple Windows Forms controls with a single ToolTip, then you can simply call the ToolTip's Dispose method.
Consider the following sample code in a Windows Forms application. The code in the CreateControls() method creates a number of TextBox controls, calls ToolTip.SetToolTip to assign a ToolTip caption to each Control, and adds the Control to an internal ObservableCollection, and to the Controls collection. The code in the RemoveControls() method walks over the ObservableCollection, gets a reference to each Control and then removes it from the ObservableCollection and the Form's Controls collection, and then calls its Dispose method. This results in each of the TextBox controls being removed from the Form and Disposed, but the instance of each TextBox and associated ToolTipInfo are still rooted in the managed heap. Uncommenting the specified line in the RemoveControls() method disassociates the TextBox from the ToolTip and allows it to be garbage collected.
public partial class Form1 : Form
toolTip = new ToolTip();
list = new ObservableCollection<TextBox>();
private void button1_Click(object sender, EventArgs e)
private void button2_Click(object sender, EventArgs e)
private void CreateControls()
for (int i = 0; i < 100; i++)
TextBox t = new TextBox();
t.Left = (t.Width * i) + 5;
private void RemoveControls()
for (int i = list.Count-1;i>=0;i--)
TextBox tb = list[i];
//Uncomment this line to disassociate the ToolTip control from the Windows Forms Control
// toolTip.SetToolTip(tb, "");
文章識別碼：2749543 - 最後檢閱時間：2012年8月24日 - 修訂： 1