[英]Infragistics UltraDropDown not displaying
我有一個基礎設施網格控件,該控件具有兩列:一個字符串顯示某些設置的名稱,另一個字符串包含一個下拉菜單,其中包含與之關聯的名稱的可用值。 所有值都相同。 實例化下拉列表並將其添加到控件后,我將其添加到了設計器中,如下所示:
Me.settingLevelDrpDown.DataSource = MyDict.ToList()
Me.settingLevelDrpDown.ValueMember = "Key"
Me.settingLevelDrpDown.DisplayMember = "Value"
在這種情況下, MyDict
是一個Dictionary(Of MyEnum, String)
,其中MyEnum
只是一個枚舉。 顯示這些的代碼是:
settingLevelDrpDown.Visible = True
settingLevels.DisplayLayout.Bands(0).Columns(1).ValueList = settingLevelDrpDown
到目前為止,我遇到兩個問題:
第一個是,當我顯示一個下拉列表時,我得到一個表,其中包含一行Key
和一個枚舉鍵列表,以及一行Value
與我實際想要顯示的字符串列表。 如何確保枚舉鍵綁定到下拉選項,同時確保顯示字符串值?
第二是性能。 我已經閱讀了本節的第三部分,據我所知,我並沒有偶然發現列出的任何要點,但是加載時間確實很慢,即使在加載表單之后,應用程序也會超硬。
對於這兩個問題的任何幫助將不勝感激。
我會盡量避免在您的代碼中使用UltraDropDown。
我只使用列的ValueList屬性。
假設您的MyDict是此類的一個實例
Dim myDict As Dictionary(Of Int32, String) = New Dictionary(Of Int32, String)
我會用這樣的方法在ValueList中對其進行轉換
Public Function ToValueList(settings As Dictionary(Of Int32, String)) As ValueList
Dim result As ValueList = New ValueList()
For Each kvp As KeyValuePair(Of Int32, String) In settings
result.ValueListItems.Add(kvp.Key, kvp.Value)
Next
Return result
End Function
現在,在網格的InitializeLayout事件中,您可以編寫
Dim b as UltraGridBand = settingLevels.DisplayLayout.Bands(0)
' Just to avoid the user typing something not expected
' Default is an editable DropDown
b.Columns(1).Style = ColumnStyle.DropDownList
b.Columns(1).ValueList = ToValueList(MyDict)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.