IntroductionWhen you have a large text on a combo box and you want to show tooltip text while selecting an item form dropdown, there is no Dropdown property which can show a tooltip based on user selection like this. But here is some simple line of code by which you can achieve it private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
string DropDownText;
if (e.Index == -1)
{
DropDownText = string.Empty;
}
else{
DropDownText = this.comboBox1.GetItemText(comboBox1.Items[e.Index]);
}
e.DrawBackground();
using (SolidBrush br = new SolidBrush(e.ForeColor))
{
e.Graphics.DrawString(DropDownText, e.Font, br, e.Bounds);
}
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
toolTip1.Show(DropDownText, comboBox1, e.Bounds.Right, e.Bounds.Bottom);
}
} Note. - You need to change property of Dropdown , Drawmode to OwnerDrawFixed for the this /li>
2. Drag and Drop a tooltip to your form where this drop down exists. Enjoy the simple article.thank you for reading. |