winform DataGridView双击修改单元格的值 分类: DataGridView 2014-08-04 19:39 150人阅读 评论(0) 收藏
定义全局变量
string abcmycode = "";//当前行自编号
bool tf = false;//是否双击
//双击可编辑
private void dgvOutClassVerify_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
if (dgvOutClassVerify.Rows.Count > 0) {
abcmycode = dgvOutClassVerify.CurrentRow.Cells["MainTop_Mycode"].Value.ToString();
dgvOutClassVerify.CurrentRow.Cells["MainTop_Mycode"].ReadOnly = false;
tf = true;
}
}
private void dgvOutClassVerify_CellValidated(object sender, DataGridViewCellEventArgs e) {
try {
if (tf == true) {
tf = false;
if (dgvOutClassVerify.Rows.Count > 0) {
int abcid = Convert.ToInt32(dgvOutClassVerify.CurrentRow.Cells["MainTop_ID"].Value.ToString());
string mycodes = dgvOutClassVerify.CurrentRow.Cells["MainTop_Mycode"].Value.ToString();
if (abcmycode != mycodes) {
if (mycodes.Equals("")) {
PublicClass.ShowMessage("自编号不能为空!");
dgvOutClassVerify.CurrentRow.Cells["MainTop_Mycode"].Value = abcmycode;
return;
}
//验证语句
//----------------------------
//更新语句
string cbasql = "update T_OutIn_MainTop set MainTop_MyCode='" + mycodes + "' where MainTop_ID= " + abcid;
int nn = DataAccess.ExecuteNonQuery(cbasql, false, null);
if (nn > 0) {
dgvOutClassVerify.CurrentRow.Cells["MainTop_MyCode"].ReadOnly = true;
PublicClass.ShowMessage("自编号修改成功!");
return;
}
}
}
}
} catch (Exception ex) {
PublicClass.ShowMessage(ex.Message);
return;
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
winform DataGridView双击修改单元格的值 分类: DataGridView 2014-08-04 19:39 150人阅读 评论(0) 收藏的更多相关文章
- hash值的计算与转换 分类: ACM TYPE 2015-05-07 17:49 36人阅读 评论(0) 收藏
#include <bits/stdc++.h> using namespace std; const int MAXN = 100; const int X = 3; long long ...
- 跨服务器修改数据 分类: SQL Server 2014-08-21 21:24 316人阅读 评论(0) 收藏
说明: 两个服务器: 192.168.0.22 A 192.168.0.3 B 数据库备份在A上 数据库在B上 在A上写: exec sp_addlinkedserver 'ITSV ...
- winform datetimepacker 开始日期 结束日期 分类: WinForm 2014-07-15 19:14 124人阅读 评论(0) 收藏
dtpStart;//开始日期 dtpEnd;//结束日期 1:开始日期小于结束日期 加载dtpEnd的ValueChanged事件即可. //开始日期小于结束日期 private v ...
- winform datagridview如何获取索引 分类: DataGridView 2014-04-11 13:42 216人阅读 评论(0) 收藏
datagridview.CurrentCell.RowIndex; 是当前活动的单元格的行的索引 datagridview.SelectedRows ; ...
- winform DataGridView 导出到Excel表格 分类: WinForm 2014-07-04 10:48 177人阅读 评论(0) 收藏
public bool ExportDataGridview(DataGridView gridView) { if (gridView.Rows.Count ...
- winform Label与DataGridView右对齐 分类: WinForm 2014-05-19 20:51 446人阅读 评论(0) 收藏
实现Label与DataGridView对齐有两种方法,差别不大: 定义: Label名称:lblName DataGridView名称:dgvData 第一种: lblName.Location = ...
- winform清空DataGridView中的数据 分类: DataGridView 2014-05-19 20:56 180人阅读 评论(0) 收藏
我们一般要把dgv情况,一般用: DataTable dt = (DataTable)dgvData.DataSource; dt.Rows.Clear(); dgvData.DataSource = ...
- Oracle 字符集的查看和修改 分类: H2_ORACLE 2013-06-19 16:52 316人阅读 评论(0) 收藏
一.什么是Oracle字符集 Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE 支持国家语言的体系结构允许你使用本地化语言来存储,处理,检索数据.它使数据库 ...
- DataGridView 添加行 分类: DataGridView 2014-12-07 08:49 263人阅读 评论(0) 收藏
说明: (1)dgvGoods 是DataGridView名 (2)index 是最大行索引 一. DataGridViewRow row = new DataGridViewRow(); int i ...
随机推荐
- C# 绘制窗体客户非客户区要用WM_PAINT和WM_NCPAINT
窗体分为两部分:客户区(Client area)和非客户区(Non-Client area) WM_PAINT消息.OnPaint()方法.GetDC()API函数都是处理窗体客户区绘制的 而标题 ...
- ACM YTU 2018 母牛的故事
母牛的故事 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- C++重载流插入运算符和流提取运算符【转】
C++的流插入运算符“<<”和流提取运算符“>>”是C++在类库中提供的,所有C++编译系统都在类库中提供输入流类istream和输出流类ostream.cin和cout分别是 ...
- CSS and JavaScript Bundling and Minification in ASP.NET 4.5
ASP.NET 4.5 includes a new feature to minify and bundle CSS and JavaScript within your web applicati ...
- 关于python decode()和 encode()
1.先收集一下这几天看到的关于decode()解码和encode()编码的用法 bytes和str是字节包和字符串,python3中会区分bytes和str,不会混用这两个.字符串可以编码成字节包,而 ...
- 监视/etc/passwd文件是否正常
帮助监视/etc/passwd文件是否正常(P90 练习6.7) 1)找出有UID0的所有项 2)找出有重复UID的所有项 3)找出有重复登录名的所有项 4)找出没有口令的所有项 5)找出没有作废日期 ...
- WPF实现导航的几种方式
下面是展示的是几种导航方式: 我们来具体看下xaml文件 <Page x:Class="WPF实现Navigation.Page1" xmlns="http://s ...
- URL encode 与 URL decode 的C语言实现
转载自:http://blog.csdn.net/langeldep/article/details/6264058 本文代码为从PHP代码中修改而来,只保留了2个函数. int php_url_de ...
- 应用git(SSH设置)
git配置完成email和user后,才可以生成SSH Key. $ git config --global user.name "自定义名称" $ git config --gl ...
- Rails中的测试RSpec升级遇到的问题
bundle exec rspec spec/ /home/wuxj/Prac/rrprac/sample_app/spec/spec_helper.rb::in `block in <top ...