How do you databind a ComboBoxCellType to a datasource

Posted by: john-shugart on 8 September 2017, 2:18 pm EST

  • Posted 8 September 2017, 2:18 pm EST

    How can I bind my comboBoxCelltype to a regular comboBox with a datasource. I know this has to be simple, but I can't seem to get it.


    Thanks in advance,


    John

  • Replied 8 September 2017, 2:18 pm EST

    Hello John,


    There is no direct way to bind the items in our combobox celltype to a DataSource. You would need to programatically loop your DataSet, get the items and creating a string array to set as the Items property of the combobox celltype.


    Or you can try creating a single column MultiColumnComboBoxCellType and sets the DataSource using DataSourceList property for the list portion of the combo box.


    Please have a look at the attached sample and let us know your further observations on the same.


    Hope this will help you. Thanks.


    2010/04/SetComboxCellTypeDatasource.zip
  • Replied 8 September 2017, 2:18 pm EST

    You can create a new CellType that inherits from comboBoxCelltype and expose the properties that you need to bind to the data source. Here is an example of the how I do it. If you need it, I can send the custom cell type code as well.

     

    FieldComboBoxCellType FieldComboBox = new FieldComboBoxCellType();
    this.fpSpreadMatching_Sheet1.Columns[0].DataField = "Field";
    this.fpSpreadMatching_Sheet1.Columns[0].Label = "Field";
    this.fpSpreadMatching_Sheet1.Columns[0].CellType = FieldComboBox;
    this.fpSpreadMatching_Sheet1.Columns[0].Locked = false;
    FieldComboBox.ListItems = (List)Presenter.Context.DataProject.Domains.Current.GetScalarFieldDefinitions();
    FieldComboBox.AutoSearch = FarPoint.Win.AutoSearch.SingleCharacter;
    FieldComboBox.Editable = false;
    FieldComboBox.MaxDrop = 8;
    this.fpSpreadMatching_Sheet1.Columns[0].Width = 150;
     

    Hope that it helps. 

Need extra support?

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

Learn More

Forum Channels