DevExpress GridView添加按钮列

在gridview上右键,选择run designer

null
图片[1]-DevExpress GridView添加按钮列-yiteyi-C++库
图片[2]-DevExpress GridView添加按钮列-yiteyi-C++库
图片[3]-DevExpress GridView添加按钮列-yiteyi-C++库

//动态变换按钮类型

private void gridView2_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)

        {

            if (e.Column.FieldName == “xxxx”)

            {

                if (gridView2.GetRowCellValue(e.RowHandle, “xxxx”).ToString() == “未绑定”)

                {

                    repositoryItemButtonEdit2.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Plus;

                }

                else

                {

                    repositoryItemButtonEdit2.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Clear;

                }

            }

        }

        private void repositoryItemButtonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)

        {

            if (repositoryItemButtonEdit2.Buttons[0].Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Plus)

            {

                BindOrderToLine();

            }

            else

            {

                DeleteBindOrderToLine();

            }

        }

//按钮列中有多个按钮,根据点击不同的按钮,响应不同的事件

        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)

        {

            int index = gridView2.GetFocusedDataSourceRowIndex();//获取数据行的索引值,从0开始

            if (index < 0)

            {

                return;

            }

            string orderID = gridView2.GetRowCellValue(index, “orderID”).ToString();

            string lineName = gridView2.GetRowCellValue(index, “lineName”).ToString();

            //

            switch ( e.Button.Index )

            {

                case 0:

                    break;

                case 1:

                    break;

                case 2:

                    break;

                case 3:

                    break;

            }           

        }

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容