您好,登錄后才能下訂單哦!
首先工具欄加入FarPoint.Win.Spread.FpSpread。假如命名為fpSpread1。
定義一個DataTable
System.Data.DataTable pDT = new System.Data.DataTable("T_Sex"); //set columns names pDT.Columns.Add("SexCode", typeof(System.String)); pDT.Columns.Add("Sex", typeof(System.String)); pDT.Columns.Add("SexName", typeof(System.String)); //Add Rows System.Data.DataRow mDR = pDT.NewRow(); mDR["SexCode"] = "M"; mDR["Sex"] = "男"; mDR["SexName"] = "男"; pDT.Rows.Add(mDR); mDR = pDT.NewRow(); mDR["SexCode"] = "F"; mDR["Sex"] = "女"; mDR["SexName"] = "女"; pDT.Rows.Add(mDR);
定義一個MultiColumnComboBoxCellType
FarPoint.Win.Spread.CellType.MultiColumnComboBoxCellType mMCCBCT = new FarPoint.Win.Spread.CellType.MultiColumnComboBoxCellType(); mMCCBCT.DataSourceList = pDT; mMCCBCT.DataMemberList = "T_Sex"; mMCCBCT.EditorValueChanged += mMCCBCT_EditorValueChanged; mMCCBCT.ListWidth = 500; mMCCBCT.ListResizeColumns = FarPoint.Win.Spread.CellType.ListResizeColumns.ByDataType; mMCCBCT.AutoSearch = FarPoint.Win.AutoSearch.MultipleCharacter; mMCCBCT.AcceptsArrowKeys = FarPoint.Win.SuperEdit.AcceptsArrowKeys.AllArrows; mMCCBCT.ColumnEditName = "SexName"; mMCCBCT.DataColumnName = "Sex"; this.fpSpread1.Sheets[0].Cells.Get(1, 1).CellType = mMCCBCT; this.fpSpread1.Sheets[0].Cells[1, 1].Value = "男";
ComboBox聯動處理,添加事件fpSpread1_ComboCloseUp
private void fpSpread1_ComboCloseUp(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e) { try { this.fpSpread1.ActiveSheet.Cells[e.Row, e.Column + 1].Value = this.fpSpread1.ActiveSheet.Cells[e.Row, e.Column].CellType.GetEditorValue(); return; } catch { } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。