-4

Tool Tip Text on Mouse Over Particular ListView Sub Item in C# . What is the code for it ?

  protected void mouse_over(object sender , Eventargs e)

{

ToolTip tooltp = new ToolTip();
ListViewItem lsvItem = ListView1.GetItemAt(e.Location.X , e.Location.Y);

if (lsvItem .subItems[0].Text = "XXX")
{
tooltp.SetToolTip(ListView1 , "HI");

}

}

But the problem I am facing is that the Entire ListView row is showing the Tool Tip instead of particaular ListView sub item ?

Alfee
  • 1
  • 2
  • 2
    Welcome to Stack Overflow. This is not a good way to ask a question here. Did you try _anything_ so far to solve your problem? Show your effort first so people might show theirs. Please read [FAQ], [ask] and [help] as a start.. – Soner Gönül Apr 02 '14 at 11:50
  • 2
    This question looks more like a google search than a SO question – Michel Ayres Apr 02 '14 at 11:57
  • possible duplicate of [How to set tooltip for a ListviewItem](http://stackoverflow.com/questions/2730931/how-to-set-tooltip-for-a-listviewitem) – Michel Ayres Apr 02 '14 at 12:02
  • As mentioned. Welcome to SO but please show your working. We're all reviewing your first post here. HTH – Crowie Apr 02 '14 at 12:06

1 Answers1

1

Set the ListView's ShowItemToolTips property to true. Also, Use ListViewItem.ToolTipText Property

// Declare the ListView.
private ListView ListViewWithToolTips;
private void InitializeItemsWithToolTips()
{

    // Construct and set the View property of the ListView.
    ListViewWithToolTips = new ListView();
    ListViewWithToolTips.Width = 200;
    ListViewWithToolTips.View = View.List;

    // Show item tooltips.
    ListViewWithToolTips.ShowItemToolTips = true;

    // Create items with a tooltip.
    ListViewItem item1WithToolTip = new ListViewItem("Item with a tooltip");
    item1WithToolTip.ToolTipText = "This is the item tooltip.";
    ListViewItem item2WithToolTip = new ListViewItem("Second item with a tooltip");
    item2WithToolTip.ToolTipText = "A different tooltip for this item.";

    // Create an item without a tooltip.
    ListViewItem itemWithoutToolTip = new ListViewItem("Item without tooltip.");

    // Add the items to the ListView.
    ListViewWithToolTips.Items.AddRange(new ListViewItem[]{item1WithToolTip, 
        item2WithToolTip, itemWithoutToolTip} );

    // Add the ListView to the form.
    this.Controls.Add(ListViewWithToolTips);
    this.Controls.Add(button1);
}
Michel Ayres
  • 5,891
  • 10
  • 63
  • 97