C#工具提示问题与列表框项目中的行有关 [英] C# tooltip issue with lines from listbox items
本文介绍了C#工具提示问题与列表框项目中的行有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有这个代码可以让所有列表框项目显示在工具提示中但它不起作用,我总是得到一个项目才能显示,任何帮助appreaciated
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
foreach (string s in listBox1.Items)
{
toolTip1.SetToolTip(txtDescription, s );
}
推荐答案
SetToolTip
方法 设置 工具提示的文本 - 它不会向其附加文本(或者它将被称为AddTooTipText
)。您需要汇编单个文本字符串以设置值:
TheSetToolTip
method sets the text of the tooltip - it does not append text to it (or it would be calledAddTooTipText
instead). You need to assemble a single text string to set the value with:
StringBuilder sb = new StringBuilder();
foreach (string s in listBox1.Items)
{
sb.AppendLine(s);
}
toolTip1.SetToolTip(txtDescription, sb.ToString());
这篇关于C#工具提示问题与列表框项目中的行有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文