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 ...
随机推荐
- JSON解析总结2
使用json-lib-2.4-jdk15.jar JSON工具类: import java.util.List; import net.sf.json.JSONArray; import net.sf ...
- Oracle数据库作业-3 查询
1. 查询Student表中的所有记录的Sname.Ssex和Class列.
- asp.net获取select值的方法
如何使用asp.net获取select值?搜索中发现一个不错的例子,在此与大家分享. 代码: <select runat="server" class="xgxxb ...
- java模拟有验证码的Http登陆
所需资源下载链接(资源免费,重在分享) Tesseract:http://download.csdn.net/detail/chenyangqi/9190667 jai_imageio-1.1-alp ...
- VS2015环境下Crystal Reports(水晶报表)的安装使用
1.首先下载Crystal Reports13对于Visual Studio 2015支持的2个文件. CRforVS_13_0_17 CRforVS_redist_install_64bit_13_ ...
- Android Bitmap那些事之如何优化内存
前言:”安得广厦千万间,大庇天下寒士俱欢颜“——杜甫.在帝都住的朋友们都可能会遇到租房子困难的问题(土豪请无视),找房子真是力气活,还耗费时间,占用我宝贵的写博客时间,没办法,谁让咱没钱还想住的好点, ...
- 简单bat语法
一.简单批处理内部命令简介 1.Echo 命令 打开回显或关闭请求回显功能,或显示消息.如果没有任何参数,echo 命令将显示当前回显设置. 语法 echo [{on off}] [message] ...
- 第八篇、封装NSURLSession网络请求框架
主要功能介绍: 1.GET请求操作 2.POST请求操作 1.处理params参数(例如拼接成:usename="123"&password="123" ...
- Objective-C 【电商APP应用代码-系统分析-详细注释-代码实现】
------------------------------------------- 电商APP应用 ************************************************ ...
- PHP的final、抽象类和方法
final关键字的用法 final class Computer{ //无法继承的类 final public function run(){ //无法继承的方法 } } class NoteBook ...