You can create a combo box cell with multiple columns in the drop-down list. You can provide a drop-down list and allow the user to choose from a displayed list. You specify the list of items by binding the cell. You can also choose which column is displayed in the edit area of the cell.
For details on the properties and methods for the multi-column combo box cell type, refer to the MultiColumnComboBoxCellType class in the Assembly Reference.
For details on the combo cell type, refer to the ComboBoxCellType class in the Assembly Reference.
Return to the overview of graphical cell types at Working with Graphical Cell Types.
Using Code
- Define the multi-column combo cell type by creating an instance of the MultiColumnComboBoxCellType class.
- Create a dataset.
- Specify the list of options by binding.
- Set the display properties such as ShowButton.
- Assign the cell type to a specific cell.
Example
Display a multi-column combo cell.
C# | Copy Code |
---|---|
string conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source= C:\\Patients2000.mdb"; string sqlStr = "SELECT * FROM Patients"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(conStr); System.Data.DataSet ds = new System.Data.DataSet(); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn); da.Fill(ds); FarPoint.Web.Spread.CellType.MultiColumnComboBoxCellType mcombo = new FarPoint.Web.Spread.CellType.MultiColumnComboBoxCellType(); mcombo.DataSource = ds; mcombo.DataColumnName = "Patients"; mcombo.ShowButton = True; fpSpread1.Sheets[0].Cells[0, 0].CellType = mcombo; |
VB | Copy Code |
---|---|
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source= C:\Common\Patients2000.mdb" Dim sqlStr As String = "SELECT * FROM Patients" Dim conn As New System.Data.OleDb.OleDbConnection(conStr) Dim ds As System.Data.DataSet = New System.Data.DataSet() Dim da As New System.Data.OleDb.OleDbDataAdapter(sqlStr, conn) da.Fill(ds) Dim mcombo As New FarPoint.Web.Spread.MultiColumnComboBoxCellType() mcombo.DataSource = ds mcombo.DataColumnName = "Patients" mcombo.ShowButton = True FpSpread1.Sheets(0).Cells(0, 0).CellType = mcombo |
Using the Spread Designer
- In the work area, select the cell or cells for which you want to set the cell type.
- Select the Home menu.
- Select the SetCellType icon under the CellType section.
- Select the cell type and any other cell properties.
- Select OK to close the dialog.
- Click Apply and Exit to close the Spread Designer.