We have several drop downs in our app with fixed values that get used repeatly in the application. How can we create a custom user control that inherits from UltraComboEditor with a fixed value list? We have tried a few things, most recently the code below. With the code below, we end up the the value list repeatly appending and therefore the values show multiple times at runtime. Is there a way to create a custom user control with a fixed value list?
Public Class ComboTaxFlag Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. Me.ValueList.ValueListItems.Clear() Me.ValueList.ValueListItems.Add(E_TAXFLAG.YES, "Yes") Me.ValueList.ValueListItems.Add(E_TAXFLAG.NO, "No") Me.ValueList.ValueListItems.Add(E_TAXFLAG.TAX1, "Tax 1") Me.ValueList.ValueListItems.Add(E_TAXFLAG.TAX2, "Tax 2") Me.Value = E_TAXFLAG.YES End SubEnd Class
Thanks, this looks like it will work for us. We have several EXEs and dialog forms in DLLs that use the same drop downs. This is one more thing simplified as a user control.
If you are still stuck, Vince Macdonad Helped me sort this out;
Here is the source code for my control if anybody wants to know how to do it
Public Class ipUltraComboEditorYesNo
Inherits Infragistics.Win.UltraWinEditors.UltraComboEditor
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
If Not Me.DesignMode Then
Dim ValueListItem1 As Infragistics.Win.ValueListItem = New Infragistics.Win.ValueListItem
Dim ValueListItem2 As Infragistics.Win.ValueListItem = New Infragistics.Win.ValueListItem
ValueListItem1.DataValue = "ValueListItem0"
ValueListItem1.DisplayText = "Yes"
ValueListItem2.DataValue = "ValueListItem1"
ValueListItem2.DisplayText = "No"
Me.Items.AddRange(New Infragistics.Win.ValueListItem() {ValueListItem1, ValueListItem2})
End If
End Sub
Private Sub InitializeComponent()
CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ipUltraComboEditorYesNo
Me.DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList
Me.LimitToList = True
CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Class
Hi,
You don't really need to derive a control. There are a bunch of ways you could do this much more easily.
If you are using the latest version of the controls, then you can simply assign the ValueList property on each UltraComboEditor control to the same ValueList.
Or, you could create a data source, like UltraDataSource or maybe a List<T> or BindingList<T> and bind each UltraComboEditor to the same list.