Develop/.NET
WinForm의 ListBox에서 툴팁표시
baragi76
2012. 2. 28. 22:02
1. 툴팁을 넣으려고 하는 Form에 ToolTip 컨트롤을 삽입.
--> ListToolTip
2. 이벤트 핸들러 추가 ( Onload 등 )
this.lbListBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbListBox_MouseMove);
3. 처리 메소드 추가
private void lbListBox_MouseMove (object sender, MouseEventArgs e)
{
int index = lbListBox.IndexFromPoint(e.Location);
if (index != -1 && index < lbListBox.Items.Count)
{
if (
ListToolTip .GetToolTip(lbListBox) != lbListBox.Items[index].ToString())
{
ListToolTip .SetToolTip(lbListBox, lbListBox.Items[index].ToString());
}
}
}