FarPoint Spread MultiColumnComboBox用法示例
首先工具栏加入FarPoint.Win.Spread.FpSpread。假如命名为fpSpread1。
定义一个DataTable
System.Data.DataTablepDT=newSystem.Data.DataTable("T_Sex");//setcolumnsnamespDT.Columns.Add("SexCode",typeof(System.String));pDT.Columns.Add("Sex",typeof(System.String));pDT.Columns.Add("SexName",typeof(System.String));//AddRowsSystem.Data.DataRowmDR=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.MultiColumnComboBoxCellTypemMCCBCT=newFarPoint.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
privatevoidfpSpread1_ComboCloseUp(objectsender,FarPoint.Win.Spread.EditorNotifyEventArgse){try{this.fpSpread1.ActiveSheet.Cells[e.Row,e.Column+1].Value=this.fpSpread1.ActiveSheet.Cells[e.Row,e.Column].CellType.GetEditorValue();return;}catch{}}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。