-1

My question is whether is it possible to fetch some values from database to show as a tooltip, for particular values in listBox?

Scenario:

I have few items in listBox,say for example red, yellow, white.

When i select / bring my mouse arrow / focused near any one of the item , the tooltip must display..for example, if red, then tooltip should display "primary color", if "yellow" ,then tooltip should display "secondary color".

I had stored the "primary color","secondary color",.. , the tooltip that must be showed when focused, in the database.

My question is whether is it possible to fetch some values from database to show as a tooltip, for particular values in listbox?

4

1 回答 1

0

您可以通过将此方法挂钩到列表框的鼠标移动事件来做到这一点

using System.Windows.Forms;

private void onMouseMove(object sender, MouseEventArgs e)
{
   if(sender is ListBox)
   {  
      ListBox listBox = (ListBox)sender;
      Point point = new Point(e.X, e.Y);
      int hoverIndex = listBox.IndexFromPoint(point);
      if(hoverIndex >= 0 && hoverIndex < listBox.Items.Count)
      {
         ToolTip tt = new ToolTip();
         tt.SetToolTip(listBox, "GetYourCustomTooltiphere");
      } 
   }    
}
于 2013-07-21T11:51:24.360 回答