C1ComboxBox: Creating a MultiColumn ComboBox from DataBaseData with HTMLPattern

Posted by: andreas.kren on 8 October 2019, 3:06 pm EST

    • Post Options:
    • Link

    Posted 8 October 2019, 3:06 pm EST - Updated 4 October 2022, 12:42 am EST

    Hi,

    I finally found the C# C1ComboBox Sample for creating a MultiColumn ComboBox

    In the sample the HTML Pattern uses a class to which it references the names of the used field. Since I got an error when diretcly using a Datatable (for ItemsDataSource) I chanfed my code to also using a class. I however still get the same error. (attached jpg)

    I uses this code for setting the ComboBox

    Private Sub ErstelleBindingSourceFürWarengruppe()
        Dim WGrpen As New List(Of WGrp)
    
        Cmd.CommandText = "Select WGr, Stc, Bez From [Warengruppe] Order by WGr, Stc"
        DbRd = Cmd.ExecuteReader()
        Try
            Do While DbRd.Read()
                Dim x As New WGrp
                x.WGrpId = DbRd("WGr")
                x.Stc = DbRd("Stc")
                x.Bez = DbRd("Bez")
                WGrpen.Add(x)
            Loop
        Catch ex As Exception
    
        End Try
    
        Call DbRd.Close()
    
        Me.ccmbSWGrp.ItemsDataSource = WGrpen
        Me.ccmbSWGrp.ItemMode = C1.Win.C1Input.ComboItemMode.HtmlPattern
        Me.ccmbSWGrp.HtmlPattern = "<table><tr><td width=80 align=right>{WgrpId}</td><td width=100>{Bez}</td></tr><table>"
        Me.ccmbSWGrp.ItemsValueMember = "WGrpId"
        Me.ccmbSWGrp.ItemsDisplayMember = "WGrpId"
    End Sub
    

    And use this class defined within the form.

    Private Class WGrp
        Public WGrpId As Integer
        Public Stc As Integer
        Public Bez As String
    End Class
    

  • Posted 8 October 2019, 3:07 pm EST

    I get the attached error when clicking the dropdown button of the combobox

  • Posted 10 October 2019, 3:32 am EST

    push. ? Anyhelp?

  • Posted 10 October 2019, 4:07 am EST

    Hi,

    C1ComboBox looks for the data source object’s “properties” (in case of List data source) to populate the list items.

    Your ‘WGrp’ class only has “fields”. You would need to declare these fields as properties:

    Private Class WGrp
        Public Property WGrpId As Integer
        Public Property Stc As Integer
        Public Property Bez As String
    End Class
    

    Regards,

    Jitender

  • Posted 10 October 2019, 7:44 am EST

    Thank you, but had it with “property” before … doesnt change, same error.

    maybe I should translate the error message.

    It says sth like: " the input format is wrong." It wants to convert sth in the DateTime Format and is not able to do this …

    Not sure what the original error message would be in an English version.

    Maybe you could send me a small working sample?!

  • Posted 10 October 2019, 8:29 am EST

    With your original code, this was the exception I was getting: “System.FormatException: ‘Input string was not in a correct format.’”

    Attached is a working sample. Please see if this works for you.

    Combo_HtmlPattern_VB.zip

  • Posted 10 October 2019, 12:35 pm EST

    Thank you! I ll have a look at it

  • Posted 10 October 2019, 12:52 pm EST

    Worked with a new combox + the ‘public property’ change. Hm… thought I had tried that before, but

    THANK YOU!

  • Posted 10 October 2019, 1:20 pm EST - Updated 4 October 2022, 12:42 am EST

    Nervy follow question. Easy way of Autocomplete possible? I open the box per click, type “422” and it jumps to the list entry? Please see my jpg.

  • Posted 11 October 2019, 1:17 am EST

    Hi,

    Currently this is not possible since C1ComboBox does not receive any keyboard events while it is dropped down.

    However, we’ve asked the developers to consider this as an enhancement request for a future release [Internal Tracking ID: 401571]

    You can also look at C1Combo control which supports this behavior (however, you can’t use HtmlPattern with C1Combo).

    Regards,

    Jitender

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels