Syncfusion Multicolumn Combobox - adding Data in Design Time in Combobox

Syncfusion Multicolumn Combobox - adding Data in Design Time in Combobox

Have data in multicolumn combo box in Design Time. Custom Data Item Window to add data in combo box

 


Custom property which will help to add data in combobox


 


  
Step 1 – Create Inherited Custom Control using Syncfusion Multicolumn Combo box
 


 
 
 
Step 2 – Custom Class to hold Data item
Public Class ComboItem
    Dim strText As String
    Dim strValue As String
 
    Public Property Text() As String
        Get
            Return strText
        End Get
        Set(ByVal value As String)
            strText = value
        End Set
    End Property
 
 
    Public Property Value() As String
        Get
            Return strValue
        End Get
        Set(ByVal value As String)
            strValue = value
        End Set
    End Property
End Class
 
 
 
Step – 3 Add Property in Main Class which has inherited the MultiColumn Combobox
 
Public Class ARCMultiColumnCombobox
 
    Private ComboItemArray() As ComboItem
 
 
<Description("Combobox Add Data Property"), Category("ARC")> _
   <EditorAttribute(GetType(ArrayEditor), GetType(System.Drawing.Design.UITypeEditor))> _
   Public Property DataItems() As ComboItem()
        Get
            Return ComboItemArray
        End Get
        Set(ByVal Value As ComboItem())
            ComboItemArray = Value
        End Set
    End Property
 
 
Public Sub FillDataItems()
        If IsNothing(ComboItemArray) = True Then Exit Sub
        If ComboItemArray.GetLength(0) > 0 Then
 
            Dim dtComboData As New DataTable
            Dim colText As DataColumn
            Dim colValue As DataColumn
 
            colText = New DataColumn("colText", System.Type.GetType("System.String"))
            colValue = New DataColumn("colValue", System.Type.GetType("System.String"))
 
            dtComboData.Columns.Add(colText)
            dtComboData.Columns.Add(colValue)
 
            For intLoop As Int16 = 0 To ComboItemArray.GetLength(0) - 1
 
                Dim Item As New ComboItem
                Item = ComboItemArray(intLoop)
 
                Dim NewRow As DataRow = dtComboData.NewRow()
                NewRow("colText") = Item.Text
                If IsNothing(Item.Value) = False Then
                    NewRow("colValue") = Item.Value
                Else
                    NewRow("colValue") = Item.Text
                End If
 
                dtComboData.Rows.Add(NewRow)
            Next
 
            Dim Dv As New DataView(dtComboData)
            Dim DtNew As New DataTable
            Dv.Sort = "colText"
 
            Me.DisplayMember = "colText"
            Me.ValueMember = "colValue"
            Me.DataSource = Dv.ToTable
 
        End If
    End Sub
 
End Class
 
 
Step – 4 Once DLL is build and Included in Project. call the below Method to load the data which is set in Design time
CboMulticolumnCombobox.FillDataItems()

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)