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

I have this code to get all listbox items to be shown in tooltip but it is not working, I always get just oneitem to be shown, any help appreaciated

C#
foreach (string s in listBox1.Items)
            {
                toolTip1.SetToolTip(txtDescription, s );
            }
Posted

1 solution

The SetToolTip method sets the text of the tooltip - it does not append text to it (or it would be called AddTooTipText instead). You need to assemble a single text string to set the value with:
C#
StringBuilder sb = new StringBuilder();
foreach (string s in listBox1.Items)
    {
    sb.AppendLine(s);
    }
toolTip1.SetToolTip(txtDescription, sb.ToString());
 
Share this answer
 
Comments
shonezi 7-Apr-13 5:08am    
THANK YOU!!!!!!!!!! I thought something like that might be the issue but NO CLUE HOW TO SOLVE IT.. THANK YOU!!!!
OriginalGriff 7-Apr-13 5:20am    
You're welcome!
Maciej Los 7-Apr-13 5:08am    
+5

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