DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx

上传人:PIYPING 文档编号:11621755 上传时间:2021-08-26 格式:DOCX 页数:3 大小:12.02KB
返回 下载 相关 举报
DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx_第1页
第1页 / 共3页
DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx_第2页
第2页 / 共3页
DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx》由会员分享,可在线阅读,更多相关《DataGridView - DataGridViewCheckBoxCell的用法介绍_.docx(3页珍藏版)》请在三一文库上搜索。

1、DataGridView - DataGridViewCheckBoxCell的用法介绍_ Datagridview是.net中最简单的控件,由于人们对表格的格式要求多种多样,所以编写一个通用的Datagridview(类似JSF中的datatable)特别困难的。 Datagridview中,用户可以对行、列、单元格进行编程。如行中可以插入下拉列表、复选框、编辑框、单选框等多种控件。每种控件都以DataGridView开头。如:单选框类为DataGridViewCheckBoxCell。 DataGridViewCheckBoxCell有一些恶心的属性熬煎了我很久,下加以具体说明。 Form

2、attedValue属性: 可能大家已经习惯了用checked=true或者checked=false这样直观的语句来取得checkbox的值,但DataGridViewCheckBoxCell没有checked属性,而用法了更简单的FormattedValue。 EditedFormattedValue属性: 当 前checkbox的状态,不管它是不是已经是一个“确认值”。在我们在印象里,checkbox只有true或false。什么叫“确认值”呢?确认值 是指:不管用户是不是已经离开该单元格(即确认该单元格最终的状态),都返回checkbox目前的值。乍一听,更糊涂了。举个例子加以说明:

3、(1) 初始时checkbox未选中,用户点了一下,于是checkbox会呈现勾选状态 这时,EditedFormattedValue=true,但FormattedValue=false,这是由于,用户没有“确认”这个值,这个checkbox仍旧处于编辑状态; (2) 初始时checkbox选中,用户点了一下,于是checkbox会呈现未勾选状态,然后用户点击其它单元格 这 时,EditedFormattedValue=false,但FormattedValue=false,这是由于,用户离开这个单元格意味着用户已经 “确认”这个值,这个checkbox不再处于编辑状态,它的EditedFo

4、rmattedValue=FormattedValue 这 时,EditedFormattedValue=false,但FormattedValue=false,这是由于,用户离开这个单元格意味着用户已经 “确认”这个值,这个checkbox不再处于编辑状态,它的EditedFormattedValue=FormattedValue 复制代码 代码如下: for (int i = 0; i dataGridView1.Rows.Count; i+) DataGridViewCheckBoxCell chkBoxCell = (DataGridViewCheckBoxCell)dataGridView1.Rowsi.CellsColumn_Id.Index; if (chkBoxCell != null (bool)chkBoxCell.EditingCellFormattedValue = true | (bool)chkBoxCell.FormattedValue = true) 更多信息请查看IT技术专栏 .

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1