I have the following code to add a combobox in a grid cell, my problem is that as you can see en the image, it is displayed empty:
I have the following class:
Public Class Priority Public Code As String Public Abbr As String End Cllass
I am feeling a list:
Dim priorityEditor As New List(Of Priority)() priorityEditor.Add(New Priority With {.Code = "High", .Abbr = "High"}) priorityEditor.Add(New Priority With {.Code = "Medium", .Abbr = "Medium"}) priorityEditor.Add(New Priority With {.Code = "Low", .Abbr = "Low"}) priorityEditor.Add(New Priority With {.Code = "Not Ready", .Abbr = "Not Ready"}) priorityEditor.Add(New Priority With {.Code = "Ready", .Abbr = "Ready"}) priorityEditor.Add(New Priority With {.Code = "Missed", .Abbr = "Missed"})
I create the dropdown
Dim priorityDropDown As New UltraCombo With { .Width = 200, .DataSource = priorityEditor, .ValueMember = "Abbr", .DisplayMember = "Abbr" }
And Finally add it to the cell
Me.DisplayLayout.Bands(0).Columns("PriorityName").EditorComponent = priorityDropDown Me.DisplayLayout.Bands(0).Columns("PriorityName").Style = ColumnStyle.DropDownList
What am I missing?
Thank you
Hello,
Thank you for posting on our forums.
When do you add the information to the cell? Can you try doing it during InitializeLayout event?
Also, if you just need a dropdown, using valueList is much better. The documentation has been archived on our website, but using this link should open it:
https://web.archive.org/web/20160428074330/http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7841
Please let me know if you need further information.
Sincerely,
Tihomir TonevSoftware DeveloperInfragistics
Hello, Tihomir, I was not able to get this working. At the end I used a function that someone created internally that returns the combobox created and with that it worked, thanks.
I am glad to hear that you have found a solution to your problem.
As the information on the link that did not work can be found useful, I will add the snippets just in case you need them in the future:
UltraDropDown in VB:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.BindUltraDropDown() End Sub Private Sub BindUltraDropDown() Dim dt As DataTable = New DataTable() dt.Columns.Add("ID", GetType(Integer)) dt.Columns.Add("DisplayText", GetType(String)) dt.Rows.Add(New Object() {1, "A"}) dt.Rows.Add(New Object() {2, "B"}) dt.Rows.Add(New Object() {3, "C"}) dt.AcceptChanges() Me.UltraDropDown1.SetDataBinding(dt, Nothing) Me.UltraDropDown1.ValueMember = "ID" Me.UltraDropDown1.DisplayMember = "DisplayText" End Sub Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout e.Layout.Bands(0).Columns("Int32 1").ValueList = Me.UltraDropDown1 End Sub
ValueList in VB:
Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout Dim vl As ValueList If (Not e.Layout.ValueLists.Exists("MyValueList")) Then vl = e.Layout.ValueLists.Add("MyValueList") vl.ValueListItems.Add(1, "A") vl.ValueListItems.Add(2, "B") vl.ValueListItems.Add(3, "C") End If e.Layout.Bands(0).Columns("Int32 1").ValueList = e.Layout.ValueLists("MyValueList") End Sub
UltraCombo
The UltraCombo can be used as a ValueList and it has essentially the same features as UltraDropDown. However, UltraCombo is intended for use as a standalone ComboBox. So while it can be used as a ValueList, there is no reason to do so. It has no advantage over UltraDropDown and has greater overhead.
In addition to being an IValueList, the UltraCombo is also an Editor. So it can also be assigned as the EditorControl of a column. This has certain advantages over the UltraDropDown, such as the ability to use a DataFilter or provide EditorButtons. But if you are not using these features, the extra overhead of UltraCombo means that the UltraDropDown is a better choice.
If you have any further questions, please let me know.