我想在 Telerik RadListBox ListItems 中隐藏一定长度的字符。
示例:(RadListBox 项目)
Welcome1
Welcome2
Welcome12345678910
就我而言,如果字符长度超过7,我想显示点点。
例如欢迎1...
当我将鼠标悬停在 Welcome1...
上时,工具提示需要显示 Welcome12345678910
如何实现这一目标?
最佳答案
如果您使用 WebForms,您可以使用下面示例中类似的方法...
标记
<telerik:RadListBox runat="server" ID="rlb" OnItemDataBound="rlb_ItemDataBound"/>
代码隐藏
protected void rlb_ItemDataBound(object sender, RadListBoxItemEventArgs e)
{
const int maxLength = 8;
if (e.Item.Text.Length <= maxLength) return;
e.Item.ToolTip = e.Item.Text;
e.Item.Text = string.Format("{0}...", e.Item.Text.Substring(0, maxLength));
}
关于javascript - Telerik RadListBox 项目列表如何隐藏字符长度并显示工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31022027/