Woody1193
Woody1193

Reputation: 7980

Infragistics UltraDropDown not displaying

I have an infragistics grid control that features two columns: one of strings showing the names of certain settings and the other with a drop-down menu containing the values available for the name it's associated with. All the values are the same. I added the drop-down in the designer after instantiating it and adding it to the control like so:

Me.settingLevelDrpDown.DataSource = MyDict.ToList()
Me.settingLevelDrpDown.ValueMember = "Key"
Me.settingLevelDrpDown.DisplayMember = "Value"

In this case, MyDict is a Dictionary(Of MyEnum, String) where MyEnum is just an enum. The code that displays these is:

settingLevelDrpDown.Visible = True
settingLevels.DisplayLayout.Bands(0).Columns(1).ValueList = settingLevelDrpDown

I'm having two issues so far:

The first is that, when I display a drop-down, I get a table with one row for Key and a list of the enum keys and a row for Value with a list of the strings I actually want to display. How can I ensure that the enum-keys are bound to the drop-down selection while ensuring that the string values are displayed?

The second is performance. I've read section three of this and, as far as I can tell, I've not stumbled on any of the points listed, yet load times are really slow and the application lags super-hard even after the forms load.

Any help with these two problems would be greatly appreciated.

Upvotes: 1

Views: 585

Answers (1)

Steve
Steve

Reputation: 216313

I would work to avoid the UltraDropDown in your code.
I would just use the ValueList property of the column.

Suppose that your MyDict is an instance of this class

Dim myDict As Dictionary(Of Int32, String) = New Dictionary(Of Int32, String)

I would transform it in a ValueList with a method like this

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

Now in your InitializeLayout event of your grid you could write

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)

Upvotes: 2

Related Questions