温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

FarPoint Spread MultiColumnComboBox用法示例

发布时间:2020-08-05 07:12:12 来源:网络 阅读:1482 作者:cnming 栏目:编程语言

首先工具栏加入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 
            {
            }
        }

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI