在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. 从模态视图push到另一个视图

    //需要给模态视图创建一个Nav,然后再调用presentViewController if (_loginVC == nil) { _loginVC = [[LoginViewController ...

  2. asp.net渐变

    简介:第一个参数代表渐变的方向,后面的StartColorStr和End就不用解释了: filter: progid:DXImageTransform.Microsoft.Gradient(Gradi ...

  3. DWZ (JUI) 教程 根据ID刷新 dialog

    reloadDialog:function(dialogId){ var dialog = $("body").data(dialogId); if(dialog){ $.pdia ...

  4. SVG之初识

    什么是SVG? 也许现在很多人都听说过SVG的人比较多,但不一定了解什么是SVG:SVG(Scalable Vector Graphics 一大串看不懂的英文)可伸缩矢量图形,它是用XML格式来定义用 ...

  5. jQuery中的DOM操作<思维导图>

    DOM是Document Object Model的缩写,意思是文档对象模型.DOM是一种与浏览器.平台.语言无关的接口.使用该接口可以轻松地访问页面中所有的标准组件.简单来说,DOM解决了Netsc ...

  6. HTML+CSS学习笔记 (11) - CSS盒模型

    元素分类 在讲解CSS布局之前,我们需要提前知道一些知识,在CSS中,html中的标签元素大体被分为三种不同的类型:块状元素.内联元素(又叫行内元素)和内联块状元素. 常用的块状元素有: <di ...

  7. Android中Socket通信案例

    以下这个案例是基于TCP/UDP协议的. 服务端实现代码 基于TCP的服务端协议 // 声明一个ServerSocket对象 ServerSocket serverSocket = null; try ...

  8. 孤岛能源安卓游戏android源码

    孤岛能源是一个以孤岛为背景的模拟动作游戏,游戏中你的角色是 Android 机器人,目的是找到该岛上充满能量的能源造福人类.游戏中,你可以选择按键操作,也可以选择触摸操作.希望你能顺利完成任务.   ...

  9. CSS3选择器:nth-child和:nth-of-type之间的差异

    CSS3选择器:nth-child和:nth-of-type之间的差异 这篇文章发布于 2011年06月21日,星期二,23:04,归类于 css相关. 阅读 57546 次, 今日 143 次 by ...

  10. javaScript 连续子数列最大和

    <!DOCTYPE html> <html> <head> <title></title> <meta charset=utf-8&g ...