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 ...
随机推荐
- 【思路,dp,BigInteger】ZOJ - 2598 Yet Another Digit
[redundant binary - 冗余二进制]:由0,1,2构成的二进制形式,基数还是2. 现给你一十进制数n,问其可转化成多少种冗余二进制形式. 首先要想到:2x = 2*2x-1 也就是说 ...
- Oracle数据库作业-4 查询
9. 查询"95031"班的学生人数.
- PHP计算中英混输字符串长度
最近做项目中碰到需要post value length check的这么一个情况 有这么一个需求, 需要backend来处理post过来的中英混输的数据. 对其限制的规则是中文10个字符, 英文20个 ...
- Cocoa Touch的3种类的交流方式delegate/target/notification
1. Delegate 在Cocoa Touch类对象运行的周期中,某一个时间点它会去调用一些指定类的指定函数来完成他自身所要完成的功能.这个”指定的类”,就称为这个类的委托类.”指定函数”则是一些在 ...
- jQuery - 中文輸入法與KeyDown/KeyPress事件
最近專案中引用了Telerik ASP.NET擴充元件AutoComplete輸入欄位,測試時發現偶爾會不聽始喚,輸入文字時無法觸發資料查詢,在Javascript Source Code裡反覆追蹤測 ...
- 【网络收集】获取JavaScript 的时间使用内置的Date函数完成
var mydate = new Date(); mydate.getYear(); //获取当前年份(2位) mydate.getFullYear(); //获取完整的年份(4位,1970-???? ...
- 集合类学习之Hashmap机制研究
1.遍历的两种实现方法 //新建 Map map=new HashMap(); //存储值 map.put() ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //遍历方式 ...
- Apache windows多线程设置
# WinNT MPM # ThreadsPerChild: constant number of worker threads in the server process # MaxRequests ...
- SQL语句统计每天的数据
按用户注册时间统计每天注册的不同来源.不同状态的用户数量: ), RegisterTime, ) RDate ,--DATEPART(YEAR, RegisterTime) 年 ) END 'AWai ...
- 20141017--类型String类
Console.Write("请输入您的身份证号"); string x=Console.ReadLine();//小string是大String的快捷方式 int i = x.L ...