DevExpress GridControl控件行内新增、编辑、删除添加选择框(转)
http://blog.csdn.net/m1654399928/article/details/21951519
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语句执行删除操作就可以了。 }
}
最后贴一张效果图:
DevExpress GridControl控件行内新增、编辑、删除添加选择框(转)的更多相关文章
- DevExpress GridControl控件行内新增、编辑、删除添加选择框
以下为内容以图片居多1234表示点击顺序 先新增一行 操作和新增数据行一样 打开ColumnEdit 选择new ButtenEdit new上方会出现一个系统命名的button 命名可以更改必须 ...
- 设置DevExpress GridControl控件时间列显示时、分、秒样式
如题,如果Dev GridControl控件绑定DataTable数据源时,DataTable中的某一列为Date类型时,GridControl默认显示样式只显示当前日期,并不会将时.分.秒显示出来. ...
- DevExpress GridControl 控件点滴
一.常用控件样式 public void setDgv(DevExpress.XtraGrid.Views.Grid.GridView gridView1) { gridView1.OptionsVi ...
- DevExpress GridControl 控件二表连动
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- DevExpress gridControl控件动态绑定列 zt
DataTable dt = =Query.GetCustome=(ref customColumnCount); //绑定列 gridView.Columns.Add(}); gridView.Co ...
- DevExpress之GridControl控件小知识
DevExpress之GridControl控件小知识 一.当代码中的DataTable中有建数据关系时,DevExpress 的 GridControl 会自动增加一个子视图 .列名也就是子表的字段 ...
- DevExpress控件的GridControl控件小结
DevExpress控件的GridControl控件小结 (由于开始使用DevExpress控件了,所以要点滴的记录一下) 1.DevExpress控件组中的GridControl控件不能使横向滚动条 ...
- 【转】Devexpress使用之:GridControl控件(合并表头)
Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的. using System; using System.Collectio ...
- Devexpress使用之:GridControl控件
Devexpress使用之:GridControl控件 Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的. using Sy ...
随机推荐
- C# 字符串 相关操作
你或许知道你能使用String.Trim方法去除字符串的头和尾的空格,不幸运的是. 这个Trim方法不能去除字符串中间的C#空格. static void Main() { ...
- iOS UI-UIPickerView(拾取器)、UIWebView(网页视图)和传值方式
// // ViewController.m // IOS_0107_finalToolClass // // Created by ma c on 16/1/7. // Copyright (c) ...
- Openwrt working with patches in the build system (8)
Reference :https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem exampl ...
- 快速切题 sgu116. Index of super-prime bfs+树思想
116. Index of super-prime time limit per test: 0.25 sec. memory limit per test: 4096 KB Let P1, P2, ...
- HDU 4791 Alice's Print Service 思路,dp 难度:2
A - Alice's Print Service Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- Python3 集合(set)(十五)
集合(set)是一个无序不重复元素的序列. 它的主要作用如下: 去重,把一个列表变成集合,就自动去重了 关系测试,测试两组数据之前的交集.差集.并集等关系 set和dict类似,也是一组key的集合, ...
- L228 the complicated issue of equality: non-disabled actors play disabled roles
Bryan Cranston’s defence of playing a wheelchair user in the new comedy-drama The Upside has underli ...
- L224 词汇题
Elaborate 精心的 preparations were being made for the Prime Minister’s official visit to the four forei ...
- Delphi发布了社区版及Delphi 10.3展望
http://altd.embarcadero.com/download/radstudio/10.2/delphicbuilder10_2_3__93231.iso,注册机在这里 注册号要自己去申请 ...
- Python中字典的基本操作
字典(Dictionary)是一映射类型(Key-value):字典是可变的,可存储任意类型对象 字典的定义用大括号{ },每个值用 ”,“ 逗号隔开,key和value使用 ”:“ 冒号分隔 字典的 ...