我正在尝试将控件中显示的文本居中(不在菜单中),但当DropDownStyle
属性设置为{{1}时,我无法找到执行此操作的方法模式。
似乎UI元素DropDownList
仅影响RadTextBoxItem\TextAllign
属性设置为DropDownStyle
模式的时间:
我如何解决这个问题?
答案 0 :(得分:1)
我相信你引用的UI元素(主要是)用于调整下拉项目。
在项目上使用TextAlignment
属性。在表单设计器中,选择Edit Items
。使用DescriptionTextListDataItems
添加商品,然后设置文字和TextAlignment
属性。如果添加RadListDataItems
,它将起作用,但下拉列表部分也将居中。
可能(应该)设置默认设置或者一个设置默认设置 - 我无法想象每个人都希望每个人都有所不同 - 例如通过UI Elements hive你正在调整,但那些似乎没有流过或映射到文字部分。
在代码中,如果您只是将字符串添加到items
集合,它将使用默认值,因此添加Description....
个对象:
Dim mi As New DescriptionTextListDataItem
mi.Text = "Over-engineered"
mi.TextAlignment = ContentAlignment.MiddleCenter
RadDropDownList1.Items.Add(mi)
请务必使用Text
而不是DescriptionText
,否则该项目将被停用。
答案 1 :(得分:0)
解决方案:
Private Sub RadDropDownList1_SelectedIndexChanged(sender As Object, e As Data.PositionChangedEventArgs) _
Handles RadDropDownList1.SelectedIndexChanged
sender.DropDownListElement.
EditableElement.
TextAlignment = ContentAlignment.MiddleCenter
End Sub
通过这种方式,我可以使用中左对齐设置列表项,并将所选项目文本显示为居中:)
PS:是的,我需要在每次selectinex发生变化时设置allignment。