Multiple Combo Boxes

Posted by: lalvarez1 on 12 April 2018, 3:26 am EST

  • Posted 12 April 2018, 3:26 am EST


    The application that I'm converting from VB 6.0 to VB 2017 uses combo boxes to display multiple values assigned to a particular cell. There can be more than one combo box (one per cell of course) depending on how many cells have more than one value assigned. Basically the application identifies those cells with multiple values by changing the background color and when the user selects that cell a combo box is shown to allow the user to select one value and return the selected value. The combo box disappears when the user moves to a different cell.

    Using Spread.NET WPF I have created the VB logic to create a Combo Box in a selected cell(s) using the example from the Spread WPF Help file (ShowDrawingObjectOnly Property) and changed Button to ComboBox but after I created multiple combo boxes using Me.GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(New MyDrawingCell(row, column) [used different row/column numbers]) and a variable that contains the values to be displayed. I placed some data in the variable used the AddRule call for a cell, then modified the variable with different data and used the AddRule for another cell. The comboboxes are displayed in the correct cell/column but the data is the same for all comboboxes. Do you have any suggestions?

    Thank you,
  • Replied 12 April 2018, 8:38 pm EST

    Hi Luis,

    You can create a control template using Combobox and then use it for editing in the cell. Please refer to the attached sample application for the implementation.

    Deepak Sharma
  • Replied 17 April 2018, 12:00 am EST

    Thank you Deepak for your response. Unfortunately it is not what I need. I have tried using your example to implement what I need in Visual Basic but have not been able to do it. Here is the functionality that I'm trying to implement.

    1. The application reads data items from a file.
    2. The application populates the spreadsheet with these data items using the row and column data contained in the file.
    3. if a cell is identified as having multiple values the application changes the cell background color and calls a subroutine to generate a combo box passing the row and column.
    4. The subroutine clears any row/column data, generates a ComboBox (non editable), populates the combo box with the values assigned to that particular cell (2 or more), selects the last data item assigned to that cell but does not display the combobox in the spreadsheet.
    5. This process continues until all data has been read. The spreadsheet might contain one or more comboboxes in different cells each with a different set of data items.

    Steps 1 through 5 are operator independent and no action is required. After the spreadsheet is populated the operator left clicks on the cell of interest, different background color, and the application makes the ComboBox visible.

    The operator then clicks on the combobox down arrow to display all the values assigned to the cell and selects one. This value is then passed to the application for further processing.

    I hope that my explanation is clear and that your Spread.NET WPF can support this logic.

    Thank you
  • Marked as Answer

    Replied 19 April 2018, 1:44 am EST

    Hi Luis,

    You can set the ComboBox for desired cells only after reading the data from cells. Or you want you can dropdown list instead of Combobox. You can get the cell values and then set it as data for DataValidator list. For example:

    gcSpreadSheet1.Sheets[0].Cells[0, 1].DataValidator = GrapeCity.Windows.SpreadSheet.Data.DataValidator.CreateListValidator("item1,item2,item3");

    where 'item1, item2 and item3 can be cell values.

    Deepak Sharma
Need extra support?

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

Learn More

Forum Channels