在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选中行的更多相关文章

  1. [zouxianghui] 清空GridPanel的checkbox选中行

    清空GridPanel的checkbox选中行,GridPanel.getSelectionModel().clearSelections();可以清空选中状态

  2. DataGridView取消默认选中行

    DataGridView在添加数据后会默认选中第 一个单元格或者第一行,我就想取消它的默认选中行.在DataGridView绑定数据之后加上了ClearSelection().这样一来,不论是启动窗体 ...

  3. Table获取checkbox选中行数据

    //检测勾选值 function checkEnter() { var Ivalue = ""; $("#dataTable tr").each(functio ...

  4. Winform DataGridView 取消默认选中行

    困境 网上有很多解决方法,可是很多读者照做并不生效.追究其原因,问题出现在许多博主没有搞清楚DataGridView绑定与当前触发事件的关系. 复现 private void Frm_Load(obj ...

  5. js获取table checkbox选中行的值.mdjs获取table checkbox选中行的

    <!DOCTYPE html> <html> <head> <script src="https://cdn.staticfile.org/jque ...

  6. 获取table中CheckBox选中行的id

    方式一 var selectList=''; jQuery(".table tbody input[type=checkbox]:checked").map(function () ...

  7. 获取DataGridView中的的选中行

    1. 获取DataGridView中的的选中行:http://blog.csdn.net/yiqijinbu/article/details/7734593 2.winform datagridvie ...

  8. datagridview 获取选中行的索引

    C# CODE for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)//遍历所有选中的行 { this.dataGrid ...

  9. 三、winForm-DataGridView操作——DataGridView 操作复选框checkbox

    一.添加复选框 ArrayList arr = new ArrayList(); public string checkboxName = "选择"; void StandLibW ...

随机推荐

  1. poj 3378 二维树状数组

    思路:直接用long long 保存会WA.用下高精度加法就行了. #include<map> #include<set> #include<cmath> #inc ...

  2. java的技术调用栈图示例

  3. 纪念大一的日子,一个简单的C++

    //Author:xtyang //记得大一学C语言,永远都不明白如何调用一个函数,真是好可爱呀. #include<iostream> using namespace std; //定义 ...

  4. 物联网 WIFI 一键配置原理(smartconfig) ESP8266/QCA4004

    自从物联网 问世以来,如何使得物  能够联网 有了很多的方式,目前运用非常广的WIFI,今天就总结下自这个方面,也对于有需要的盆友 也希望有抛砖引玉之效果. 物联网:  智能硬件+APP+云 APP ...

  5. Part 92 Significance of Thread Join and Thread IsAlive functions

    Thread.Join & Thread.IsAlive functions Join blocks the current thread and makes it wait until th ...

  6. JS验证框架(exValidation)

    exValidation是一个前台校验框架 能够校验前台的常用的输入错误. 例如,必须输入,用户输入长度...... ----------------------------------------- ...

  7. 虚拟机中Linux安装Tools

    1. 插入光盘后将文件拷贝到常用放置软件的目录 2. 解压文件 3. 然后进入解压后的文件夹里找到安装文件进行安装(注意使用root权限安装) 4. 安装时也是一个交互的过程 5. 完成安装

  8. Xcode中使用插件

    有两种添加插件的方法.推荐第二种 一.就是在Github上找到你要安装的插件,然后在Xcode完全退出后,打开你要安装的插件,编译就行了,然后完全退出后,重新打开Xcode,会出来这个图 点击load ...

  9. 对ASP.Net的认识(三)

    较为详细的整个请求处理流程 Application: BeginRequestApplication: PreAuthenticateRequestApplication: AuthenticateR ...

  10. 方法:一个简单的读取配置文件.properties的工具类 JAVA

    import java.util.ResourceBundle; public class ConfigHelper { private static ConfigHelper instance; p ...