We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

CheckedItems, which are set in code, aren't displayed in sfComboBox

 Hello,

I can determine and set the CheckedItems in the code.

However, they are not displayed in the control

Here my code:


Public Sub Stand_WG_Einstellen(cb As Syncfusion.WinForms.ListView.SfComboBox, byVal lID_Stand As Int32)

            Dim cSql As String, cMsg As String

            cSql = "Select ID, ID_Warengruppe from tblTemp_Stand_WG_Ware Where ID_Stand = " & lID_Stand

            Dim adoConn As New OleDbConnection(gcProviderACEOLEDB120 & gcDataPath & "\MC_UP\Mand" &          gcGewMandant & "\MCO_UP.accdb")

            Dim mC As New OleDbCommand(cSql, adoConn)

            Dim mDR As OleDbDataReader

            cb.CheckedItems.Clear()

            Try

                adoConn.Open()

                mDR = mC.ExecuteReader()

                While mDR.Read()

                    If Not IsDBNull(mDR("ID_Warengruppe")) Then

                        For Each oRow As Object In cb.DropDownListView.View.Items.ToList()

                            If oRow("ID") = Convert.ToInt32(mDR("ID_Warengruppe")) Then

                               cb.CheckedItems.Add(oRow("Warengruppe"))

                            End If

                        Next oRow

                    End If

                End While

            Catch err As Exception

                Beep()

                cMsg = "Setting "

                MsgBox(err.Message, MsgBoxStyle.Critical, cMsg)

            End Try

'Only for test #########################################################

            MsgBox(cb.CheckedItems.Count)

            Dim i As Integer

            For i = 0 To cb.CheckedItems.Count-1

                MsgBox(cb.CheckedItems(i).ToString)

            Next

'###################################################################

            adoConn.Close()

            adoConn = Nothing

            OleDbConnection.ReleaseObjectPool()

        End Sub

I need help. What do I wrong?
Regards
Helmut


3 Replies

GT Gokul Thanudhas Syncfusion Team October 17, 2022 09:09 AM

Hi Helmut,


We are unable to reproduce the issue from our end. Please refer to the sample and the video from the attachment for your reference.


If we misunderstood your query, please provide a sample or more information about your reported query. So, that we can prompt better solution


Regards,

Gokul T


Attachment: SfComboBox_aadfd385.zip


HE Helmut October 17, 2022 10:39 AM

Hello Gokul,

many thanks for your help in your sample.

My mistake was:

For Each oRow As Object In cb.DropDownListView.View.Items.ToList()

If oRow("ID") = Convert.ToInt32(mDR("ID_Warengruppe")) Then

       cb.CheckedItems.Add(oRow("Warengruppe"))
  End If

next oRow

I changed it to:

 For Each oRow As Object In cb.DropDownListView.View.Items.ToList()

 If oRow("ID") = Convert.ToInt32(mDR("ID_Warengruppe")) Then

                  cb.CheckedItems.Add(oRow)

  End If

next oRow

Now, all works fine!


Thank You and regards


Helmut



HN Harinath Navaneethakrishnan Syncfusion Team October 18, 2022 07:22 AM

Hi Helmut,


We are glad to know that your issue has been fixed. Please let us know if you need any other assistance. We are happy to assist you. 


Regards,

Harinath  N


Loader.
Live Chat Icon For mobile
Up arrow icon