DataGridView 使用CheckBox选中行
在winform中使用checbox很多。上次那个项目里就用到了,写了一个不太好用,后来翻阅了一下微软提供的样码,我觉得有必要给大家分享一下。
// This event handler manually raises the CellValueChanged event
// by calling the CommitEdit method.
public void DataGridView1_CurrentCellDirtyStateChanged(object sender,
EventArgs e)
{
if (DataGridView1.IsCurrentCellDirty)
{
DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
} // If a check box cell is clicked, this event handler disables
// or enables the button in the same row as the clicked cell.
public void DataGridView1_CellValueChanged(object sender,
DataGridViewCellEventArgs e)
{
if (DataGridView1.Columns[e.ColumnIndex].Name == "CheckBoxs")
{ DataGridViewCheckBoxCell checkCell =
(DataGridViewCheckBoxCell)DataGridView1.
Rows[e.RowIndex].Cells["CheckBoxs"];
if ((Boolean)checkCell.Value)
{
//处理选中
//do something
}
DataGridView1.Invalidate();
}
}
DataGridView 使用CheckBox选中行的更多相关文章
- [zouxianghui] 清空GridPanel的checkbox选中行
清空GridPanel的checkbox选中行,GridPanel.getSelectionModel().clearSelections();可以清空选中状态
- DataGridView取消默认选中行
DataGridView在添加数据后会默认选中第 一个单元格或者第一行,我就想取消它的默认选中行.在DataGridView绑定数据之后加上了ClearSelection().这样一来,不论是启动窗体 ...
- Table获取checkbox选中行数据
//检测勾选值 function checkEnter() { var Ivalue = ""; $("#dataTable tr").each(functio ...
- Winform DataGridView 取消默认选中行
困境 网上有很多解决方法,可是很多读者照做并不生效.追究其原因,问题出现在许多博主没有搞清楚DataGridView绑定与当前触发事件的关系. 复现 private void Frm_Load(obj ...
- js获取table checkbox选中行的值.mdjs获取table checkbox选中行的
<!DOCTYPE html> <html> <head> <script src="https://cdn.staticfile.org/jque ...
- 获取table中CheckBox选中行的id
方式一 var selectList=''; jQuery(".table tbody input[type=checkbox]:checked").map(function () ...
- 获取DataGridView中的的选中行
1. 获取DataGridView中的的选中行:http://blog.csdn.net/yiqijinbu/article/details/7734593 2.winform datagridvie ...
- datagridview 获取选中行的索引
C# CODE for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)//遍历所有选中的行 { this.dataGrid ...
- 三、winForm-DataGridView操作——DataGridView 操作复选框checkbox
一.添加复选框 ArrayList arr = new ArrayList(); public string checkboxName = "选择"; void StandLibW ...
随机推荐
- HDU 1233 还是畅通工程 (最小生成树)
还是畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- codeforces 590B B. Chip 'n Dale Rescue Rangers(二分+计算几何)
题目链接: B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabyte ...
- hdu 3938 并查集
思路:这题的出题人是不是语文不行啊,题目意思说不清楚. 知道是求存在路径的点对数后,用并查集每次记录集合中点的数目,很容易就解决了. #include<set> #include<c ...
- Hive通过查询语句向表中插入数据注意事项
最近在学习使用Hive(版本0.13.1)的过程中,发现了一些坑,它们或许是Hive提倡的比关系数据库更加自由的体现(同时引来一些问题),或许是一些bug.总而言之,这些都需要使用Hive的开发人员额 ...
- JavaScript之放大镜效果
在网上也浏览过许多关于JavaScript放大镜效果的文章,有的代码解释得些隐晦难懂,看的我头有点晕晕的╮(╯﹏╰)╭,我的心情是这样的: 吐槽完了,我们动动小鼠标,当鼠标经过下面这张美女图片时就实现 ...
- jQuery中的DOM操作<思维导图>
DOM是Document Object Model的缩写,意思是文档对象模型.DOM是一种与浏览器.平台.语言无关的接口.使用该接口可以轻松地访问页面中所有的标准组件.简单来说,DOM解决了Netsc ...
- java使用BufferedImage和Graphics实现图片合成
package com.igoxin.weixin.custom; import java.awt.Graphics; import java.awt.image.BufferedImage; imp ...
- ubuntu 12.04 安装 codeblock 12.11
原文地址:http://qtlinux.blog.51cto.com/3052744/1136779 参考文章:http://blog.csdn.net/dszsy1990/article/det ...
- c 语言时间的输出和比较
time_t The most basic representation of a date and time is the type time_t. The value of a time_t va ...
- XMLHTTPRequest的属性和方法简介
由于现在在公司负责制作标准的静态页面,为了增强客户体验,所以经常要做些AJAX效果,也学你也和我一样在,学习AJAX.而设计AJAX时使用的一个 重要的技术(工具)就是XMLHTTPRequest对象 ...