ComboBoxCellType CreateLotNoCellType(LookupData data) { ComboBoxCellType cell = new ComboBoxCellType(); cell.Editable = true; cell.EditorValue = EditorValue.ItemData; if ((data.DataSource) != null) { DataTable dt = data.DataSource; string[] strItems = new string[dt.Rows.Count]; string[] strItemData = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { strItemData[i] = dt.Rows[i][data.ValueMember] as string; strItems[i] = strItemData[i]; } cell.Items = strItems; cell.ItemData = strItemData; } return(cell); }
public void setComboxCellType(int iRow, int iCol) { FarPoint.Web.Spread.ComboBoxCellType combcel = new ComboBoxCellType(); String[] cbstrstts = new String[] { "样品类型1", "样品类型2", "样品类型3" }; combcel.Items = cbstrstts; _spread.ActiveSheetView.Cells[iRow, iCol].CellType = combcel; }
/// <summary> /// Create Spread's ComboBoxCellType with lookup data. /// </summary> /// <param name="data"></param> /// <param name="showDisplayMember"></param> /// <returns></returns> public static ComboBoxCellType CreateComboBoxCellType(LookupData data, bool showDisplayMember) { ComboBoxCellType cell = new ComboBoxCellType(); cell.Editable = true; cell.EditorValue = EditorValue.ItemData; if ((data.DataSource as DataTable) != null) { DataTable dt = data.DataSource; string[] strItems = new string[dt.Rows.Count]; string[] strItemData = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { strItemData[i] = dt.Rows[i][data.ValueMember] as string; if (showDisplayMember) { strItems[i] = String.Format("{0}{1}{2}", strItemData[i], Common.COMBOBOX_SEPERATOR_SYMBOL, dt.Rows[i][data.DisplayMember] ); } else { strItems[i] = String.Format("{0}", strItemData[i] ); } } cell.Items = strItems; cell.ItemData = strItemData; } return(cell); }