开发者

Splitting Titles in DropDown

开发者 https://www.devze.com 2023-01-21 02:52 出处:网络
My application Drop-d开发者_运维问答own consist of lengthy titles, which exceeds the drop-down beyond the page.

My application Drop-d开发者_运维问答own consist of lengthy titles, which exceeds the drop-down beyond the page.

Example Title: Enter your Name Up to 250 Char Enter your Name Up to 250 Char Enter your Name Up to 250 Char Enter your Name Up to 250 Char.

i can split half of the title with sub string(). Is it possible to bring the next half of the title to next line in Drop-down using C#.


I'm not aware of any property of the DropDownList control that allows you to wrap text, but when I've had items in a DropDownList that exceed the width of the control, I add a tooltip that displays the full text of the item when the mouse hovers over it.

You can do this in code-behind after you've populated the DropDownList:

C#

foreach (ListItem item in DropDownList1.Items)   
    item.Attributes.Add("Title", item.Text);

VB

For Each item As ListItem In DropDownList1.Items
    item.Attributes.Add("Title", item.Text)
End For
0

精彩评论

暂无评论...
验证码 换一张
取 消