Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to display tooltip for each item in ListBox.

What I have tried:

for this I have added below code block in page preRender event:

for (var i = 0; i < ListBox.Items.Count;i++ )
                {
                    var item = ListBox.Items[i];
                    if (item.Attributes["title"] == null)
                    { 
                        item.Attributes.Add("title", item.ToString()); 
                    }
                }


It is adding title attribute for every item but only displays tooltip for the items which are below the selected item but not for the item which is above selected item.
means: if I have 4 items in listbox and I have selected 2nd item then I am only getting tooltip for 2,3 and 4th item and not for 1st item but the attribute title is present for item 1.
if we select first list item they I am getting tooltip for all the list items.
Posted
Updated 1-Aug-17 23:03pm
Comments
Thomas Daniels 1-Aug-17 7:25am    
I just tried exactly this, and the tooltip appeared fine for all items...
Karthik_Mahalingam 1-Aug-17 8:25am    
you might be missing something, tested your code it works good.

1 solution

The tooltip is working fine. I have also verified this. i dont see any error in the code you can also try using the
SetToolTip
Method Here is link to this
C# tooltip issue with lines from listbox items[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900