以下为内容以图片居多1234表示点击顺序

先新增一行 操作和新增数据行一样

打开ColumnEdit  选择new ButtenEdit  new上方会出现一个系统命名的button

命名可以更改必须在下发name中更改 是行的name

进入click事件就和普通的按钮一样了 可以编写自己的代码了

一下代码是设计器中的代码 供大家参考

// gridColumn_update
this.gridColumn_update.Caption = "修改";
this.gridColumn_update.ColumnEdit = this.repositoryItemButtonEdit_update;
this.gridColumn_update.FieldName = "gridColumn_update";
this.gridColumn_update.Name = "gridColumn_update";
this.gridColumn_update.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
this.gridColumn_update.Visible = true;
this.gridColumn_update.VisibleIndex = ;
//
// repositoryItemButtonEdit_update
//
this.repositoryItemButtonEdit_update.AutoHeight = false;
serializableAppearanceObject1.Options.UseTextOptions = true;
serializableAppearanceObject1.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
this.repositoryItemButtonEdit_update.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "修改", -, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, null, new DevExpress.Utils.KeyShortcut(System. Windows.Forms.Keys.None), serializableAppearanceObject1, "", null, null, true)});
this.repositoryItemButtonEdit_update.Name = "repositoryItemButtonEdit_update";
this.repositoryItemButtonEdit_update.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
this.repositoryItemButtonEdit_update.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(th.repositoryItemButtonEdit_update_ButtonClick);

DevExpress控件的属性太多了 还需要大家进行一步的学习使用理解

如有错误 或更好的方法 欢迎大家指指出

出处:https://blog.csdn.net/yueliangge910101/article/details/82257676

=================================================================

 1.首先到GridControl控件设计里设置属性Repository    (In-place EditorRepository)  如下图(CheckEdit可以不添加,这是本人根据自己需求添加的):

主要设置两个两个属性 NullText,Name

2.绑定数据

关键代码如下:

DataTable dt = dbHelp.GetDataSql("select TS_NO,TS_NAME ,TS_LONGITUDE,TS_LATITUDE,TS_RANK from  dbo.LPTE_TS");

grStation.DataSource = null;
            gvStation.Columns.Clear();
            grStation.DataSource = dt;

gvStation.Columns["TS_NO"].Visible = false;
            gvStation.Columns["TS_NAME"].Visible = true;
            gvStation.Columns["TS_NAME"].Caption = "名称";
            gvStation.Columns["TS_NAME"].VisibleIndex = 1;
            gvStation.Columns["TS_RANK"].Visible = true;
            gvStation.Columns["TS_RANK"].Caption = "等级";
            gvStation.Columns["TS_RANK"].VisibleIndex = 2;
            gvStation.Columns["TS_LONGITUDE"].Caption = "经度";
            gvStation.Columns["TS_LATITUDE"].Caption = "纬度";

GridColumn addLinkHiper = new GridColumn();
            addLinkHiper.Caption = "新增";
            addLinkHiper.Visible = true;

addLinkHiper.ColumnEdit = stationAdd;
            gvStation.Columns.Add(addLinkHiper);
            addLinkHiper.VisibleIndex = 5;

GridColumn editLinkHiper = new GridColumn();
            editLinkHiper.Caption = "编辑";
            editLinkHiper.Visible = true;

editLinkHiper.ColumnEdit = stationEdit;
            gvStation.Columns.Add(editLinkHiper);
            editLinkHiper.VisibleIndex = 6;

GridColumn delLinkHiper = new GridColumn();
            delLinkHiper.Caption = "删除";
            delLinkHiper.Visible = true;

delLinkHiper.ColumnEdit = stationDel;
            gvStation.Columns.Add(delLinkHiper);
            delLinkHiper.VisibleIndex = 7;

gvStation.BestFitColumns();

以上数据已全部绑定完成

3.触发事件

在上图中点击事件Click,新增不多说,弹出新窗体即可

//编辑
        private void stationEdit_Click(object sender, EventArgs e)
        {
            int[] selectRows = gvStation.GetSelectedRows();
            //赋值
            int tsNo = Convert.ToInt32(gvStation.GetRowCellValue(selectRows[0], "TS_NO"));  //TS_NO是控件列名

//具体操作因人而异

......
        }

//删除
        private void stationDel_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定删除所选数据?", "删除提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {

int[] selectRows = gvStation.GetSelectedRows();
                //赋值
                int  tsNO = Convert.ToInt32(gvStation.GetRowCellValue(selectRows[0], "TS_NO"));

//写sql语句执行删除操作就可以了。
            }

}

最后贴一张效果图:

出处:https://blog.csdn.net/m1654399928/article/details/21951519

DevExpress GridControl控件行内新增、编辑、删除添加选择框的更多相关文章

  1. DevExpress GridControl控件行内新增、编辑、删除添加选择框(转)

    http://blog.csdn.net/m1654399928/article/details/21951519 1.首先到GridControl控件设计里设置属性Repository    (In ...

  2. 设置DevExpress GridControl控件时间列显示时、分、秒样式

    如题,如果Dev GridControl控件绑定DataTable数据源时,DataTable中的某一列为Date类型时,GridControl默认显示样式只显示当前日期,并不会将时.分.秒显示出来. ...

  3. DevExpress GridControl 控件点滴

    一.常用控件样式 public void setDgv(DevExpress.XtraGrid.Views.Grid.GridView gridView1) { gridView1.OptionsVi ...

  4. DevExpress GridControl 控件二表连动

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. DevExpress gridControl控件动态绑定列 zt

    DataTable dt = =Query.GetCustome=(ref customColumnCount); //绑定列 gridView.Columns.Add(}); gridView.Co ...

  6. DevExpress之GridControl控件小知识

    DevExpress之GridControl控件小知识 一.当代码中的DataTable中有建数据关系时,DevExpress 的 GridControl 会自动增加一个子视图 .列名也就是子表的字段 ...

  7. DevExpress控件的GridControl控件小结

    DevExpress控件的GridControl控件小结 (由于开始使用DevExpress控件了,所以要点滴的记录一下) 1.DevExpress控件组中的GridControl控件不能使横向滚动条 ...

  8. 【转】Devexpress使用之:GridControl控件(合并表头)

    Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的. using System; using System.Collectio ...

  9. Devexpress使用之:GridControl控件

    Devexpress使用之:GridControl控件 Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的. using Sy ...

随机推荐

  1. Python字符串与格式化的一点用法

    #python的基本语法网上已经有很多详细的解释了,写在这里方便自己记忆一些 1.python于C语言不同的是,python没有字符的概念,所谓的字符就是长度为1的字符串,使用切片或者索引同样可以对字 ...

  2. Vue源码之----为什么Vue中Array的pop,push等方法可以reactive,而Array[0]='a'这样的方法不会reactive?

    这就要从reactive开始讲起了,粗略的说,js的操作能引起页面上显示的改变,是因为该操作引起了组件的重新渲染,渲染会生成新的虚拟节点,新节点和旧节点会对比,操作浏览器的node进行改变. vue实 ...

  3. linux下安装FTP详细

    一:安装ftp 1.检查是否安装了 ftp :(下图是已安装的效果,没安装没有展示) rpm -qa|grep vsftpd 2.安装指令:(找一个  -y  指令) yum install -y v ...

  4. Qt 文件的操作

    文件操作是应用程序必不可少的部分.Qt 作为一个通用开发库,提供了跨平台的文件操作能力.从本章开始,我们来了解下 Qt 的文件以及输入输出的功能,也就是 I/O 系统. Qt 通过QIODevice提 ...

  5. vs code 本地请求json

    首先下载扩展live server 重新加载后 右下方工具栏会多出一个go live 点击go live,会默认启动chome,地址  http://127.0.0.1:5500 js脚本: $.aj ...

  6. Hadoop 搭建集群的步骤

    1.安装jdk,配置环境变量 root@localhost java]# vi /etc/profile 在profile中添加如下内容: #set java environmentexport  J ...

  7. cannot import name '_imaging' from 'PIL'

    学习廖雪峰官网的Python的教程,在常用的第三方模块的Pillow的学习过程中总是报错cannot import name '_imaging' from 'PIL' 解决办法: 1.下载并安装An ...

  8. nginx 配置本地https(免费证书)

    Linux系统下生成证书 生成秘钥key,运行: $ openssl genrsa -des3 -out server.key 20481会有两次要求输入密码,输入同一个即可 输入密码 然后你就获得了 ...

  9. MDK5报错missing closing quote

    用emwin做界面的时候遇到的错误,MDK5可能无法编译一些汉字编码,对应汉字在信息反馈中会显示为乱码,更会附带一些如“expected a "}"”这样的错误提示. 解决方法:O ...

  10. pytorch查看模型weight与grad

    在用pdb debug的时候,有时候需要看一下特定layer的权重以及相应的梯度信息,如何查看呢? 1. 首先把你的模型打印出来,像这样 2. 然后观察到model下面有module的key,modu ...