Exception when selecting blanc value in non-editable combo cell

Posted by: ge0force on 8 September 2017, 2:37 pm EST

  • Posted 8 September 2017, 2:37 pm EST

    The title says it all. I have 2 arrays (Items and ItemData) containing ID and Description.

    The spread seems to add one blanc row to the combo, which is great so users can select an empty value.

    But when selecting the empty value, an exception is thrown.

    Here's my code:

            Dim comboCellType1 As CellType.ComboBoxCellType = New CellType.ComboBoxCellType()
            comboCellType1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
            comboCellType1.Editable = False

            comboCellType1.EditorValue = CellType.EditorValue.ItemData
            comboCellType1.Items = Items
            comboCellType1.ItemData = ItemData

            Spread1.ActiveSheet.Columns(2).CellType = comboCellType1

  • Replied 8 September 2017, 2:37 pm EST

    Hello,

    I used the following to replicate the issue at my end using Spread 5for Windows Forms.

     Dim combo As New FarPoint.Win.Spread.CellType.ComboBoxCellType()

            Dim cbstr1 As String()

            cbstr1 = New String() {"One", "Two", "Three", " "}

            Dim strval As String()

            strval = New String() {"1", "2", "3"}

            combo.Items = cbstr1

            combo.ItemData = strval

            combo.AutoCompleteMode = AutoCompleteMode.SuggestAppend

            combo.Editable = False

            combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData

            FpSpread1.Sheets(0).Cells(0, 0).CellType = combo

    I was not able to reproduce the issue at my end. Please test the above code, let me know if I am missing something.

    Thanks,

     

     

  • Replied 8 September 2017, 2:37 pm EST

    Your code seems to work, and now I see what I did wrong. I forgot to add the " " value in the last element of my list.

            Dim pfls As List(Of Profiel_Hoofd) = Pm.GetAlleProfielen   ' Get values from database and return them as a list

            Dim Items(pfls.Count) As String
            Dim ItemData(pfls.Count) As String

            Dim intcounter As Integer = 0

            For Each fpl In pfls
                Items(intcounter) = fpl.ProfielNaam.ToString
                ItemData(intcounter) = fpl.ProfielId.ToString
                intcounter = intcounter + 1
            Next

    The array is zero-based,so ItemData(intcounter) was still nothing.

    Adding this code solved the problem:

            Items(intcounter) = " "
            ItemData(intcounter) = ""

     Thankx for your help!

Need extra support?

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

Learn More

Forum Channels