Combobox items

Posted by: giantocr on 8 September 2017, 1:40 pm EST

  • Posted 8 September 2017, 1:40 pm EST

    In FpSpread1 I have two columns of comboboxes. I need the items in column 2 to be dependant on the selection made in column 1. If the user changes their selection in column 1.

    The celltype of cells in column 1 is set to cb4 on form load. The celltype of the cells in column 2 is set to either cb, cb2 or cb3 depending on the users selection in column 1 through the ComboSelChange event.

    Public Class QBF1

        Dim cb As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        Dim cb2 As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        Dim cb3 As New FarPoint.Win.Spread.CellType.ComboBoxCellType
        Dim cb4 As New FarPoint.Win.Spread.CellType.ComboBoxCellType

    Private Sub QBF1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            cb.Items = New String() {"Equals", "Greater than", "Less than", "Greater or equal", "Less or equal", "Does not equal"}
            cb.ItemData = New String() {"=", ">", "<", ">=", "<=", "<>"}
            Dim img As New ImageList
            cb.ImageList = img

            cb2.Items = New String() {"Equals", "Starts with", "Ends with", "Contains", "Does not contain"}
            cb2.ItemData = New String() {"Equals", "Starts with", "Ends with", "Contains", "Does not contain"}
            Dim img2 As New ImageList
            cb2.ImageList = img2

            cb3.Items = New String() {"Equals"}
            cb3.ItemData = New String() {"="}
            Dim img3 As New ImageList
            cb3.ImageList = img3

            cb4.Items = New String() {"Datapoint", "Value", "Route", "Group", "System", "Location", "Parameter", "ParaDesc", "Technician"}
            cb4.ItemData = New String() {"ReadNum.Datapoint", "ReadNum.ReadingValue", "RouteGP.RouteID", "GroupDP.GroupID", "DataPoints.SystemID",   "DataPoints.LocationID", "DataPoints.ParaID", "DataPoints.ParaDC", "Sessions.TechID"}
            FpSpread1.Sheets(0).Cells(2, 3, 10, 3).CellType = cb4

    End Sub

     Private Sub FpSpread1_ComboSelChange(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EditorNotifyEventArgs) Handles FpSpread1.ComboSelChange

            If FpSpread1.Sheets(0).ActiveColumnIndex = 3 Then
                Dim acttext As String = FpSpread1.Sheets(0).ActiveCell.Text
                Dim rowNum As Integer = FpSpread1.Sheets(0).ActiveRowIndex
                Dim colNum As Integer = FpSpread1.Sheets(0).ActiveColumnIndex + 1

                If acttext = "Value" Then
                    FpSpread1.Sheets(0).Cells(rowNum, colNum).CellType = cb
                ElseIf acttext = "Route" Or acttext = "Group" Then
                    FpSpread1.Sheets(0).Cells(rowNum, colNum).CellType = cb3
                    FpSpread1.Sheets(0).Cells(rowNum, colNum).CellType = cb2
                End If
            End If
        End Sub

    This works fine the first time through. But if you make a selection in column 1 and column 2, then change the selection in column 1, it does not update the items in column 2 unless you make the change in column 1 several times. Is there anything I can do to improve the response.

    Thanks - John

  • Replied 8 September 2017, 1:40 pm EST


    By the time this event has fired, the Text property of the cell probably has not had the Text updated. Change to the following line of code and this should work for you.

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> acttext </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT><FONT size=2> = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>CType</FONT></FONT><FONT size=2>(e.EditingControl, FarPoint.Win.FpCombo).SelectedItem

  • Replied 8 September 2017, 1:40 pm EST

    Thanks. That worked great.
Need extra support?

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

Learn More

Forum Channels