Retrieve a Columns Value from MultiColumnComboBox in ComboCloseUp Event

Posted by: sheritt on 8 September 2017, 1:50 pm EST

  • Posted 8 September 2017, 1:50 pm EST

    I have a multicolumncombobox that has 5 columns.  I need to retrieve the value from column 4 of this combobox and place it in another cell.


    I know how to place it in another cell, I just don't know how to get the value.


    In the ComboCloseUp event how do I retrieve the value of the selected combo items 4th column?


    Thanks

  • Replied 8 September 2017, 1:50 pm EST

    Hello Sheritt,

    To get the value of a particular column, first you need to set the DataColumn property of the MultiColumnComboBox to the desired column and then using the Value property you can retrieve the value from desired column (Column 4 in your case). This can be done as follows:

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

           Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\Program Files\FarPoint Technologies\Spread.WinForms.4.dotNet20\Common      \Patients2000.mdb"

            Dim sqlStr As String = "SELECT * FROM Patients"

            Dim conn As New System.Data.OleDb.OleDbConnection(conStr)

            Dim ds As DataSet = New DataSet()

            Dim da As New System.Data.OleDb.OleDbDataAdapter(sqlStr, conn)

            da.Fill(ds)

            Dim mcb As New FarPoint.Win.Spread.CellType.MultiColumnComboBoxCellType()

            mcb.DataSourceList = ds

            mcb.DataColumn = 3

            mcb.ButtonAlign = FarPoint.Win.ButtonAlign.Right

            mcb.ListWidth = 500

            mcb.ListOffset = 5

            mcb.MaxDrop = 5

            FpSpread1.ActiveSheet.Cells(0, 0).CellType = mcb

        End Sub   

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

            MsgBox(e.View.Sheets(0).Cells(e.Row, e.Column).Value)

    End Sub

    Thanks

  • Replied 8 September 2017, 1:50 pm EST

    I have another column set as the datacolumn.


    What I need to do is once a user selects a value from this multicolumncombobox I need to get the information in column 4 to display in another cell.


    So the combobox will display one value from the datacolumn and a text cell will display the text value in column 4 of the combobox.


    Thanks

  • Replied 8 September 2017, 1:50 pm EST

    Hello,


    You can get the SubEditor which is the dropdown list and happens to be a Spread control. You can then get the value from this spreadsheet to put in the main Spread control.


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


    Dim combo As FarPoint.Win.Spread.FpSpread = CType(CType(e.EditingControl, FarPoint.Win.Spread.CellType.MultiColumnEditor).SubEditor, FarPoint.Win.Spread.FpSpread)


    FpSpread1.Sheets(0).SetValue(e.Row, 1, combo.Sheets(0).GetValue(combo.Sheets(0).ActiveRowIndex, 3))


    End Sub

Need extra support?

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

Learn More

Forum Channels