DataGridView 添加checkBox
来源:互联网 发布:linux 查看gpu使用率 编辑:程序博客网 时间:2024/05/22 00:24
// chk.ReadOnly = true;
chk.Width = 50;
chk.HeaderText = "状态";
dG_List.Columns.Add(chk);
DataGridView添加checkBox列
private void dG_List_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dG_List.Columns[e.ColumnIndex].HeaderText == "状态")
{
if (dG_List.Rows[e.RowIndex].Cells[6].ValueType == typeof(bool))
{
bool IsChk = (bool)dG_List.Rows[e.RowIndex].Cells[6].FormattedValue;
if (IsChk)
{
IsChk = false;
dG_List.Rows[e.RowIndex].Cells[6].Value = false;
}
else
{
IsChk = true;
dG_List.Rows[e.RowIndex].Cells[6].Value = true;
}
}
else
{
if (dG_List.Rows[e.RowIndex].Cells[6].ValueType == typeof(CheckState))
{
CheckState chk = (CheckState)dG_List.Rows[e.RowIndex].Cells[6].EditedFormattedValue;
if (chk == CheckState.Checked)
{
chk = CheckState.Unchecked;
dG_List.Rows[e.RowIndex].Cells[6].Value = false;
}
else
{
chk = CheckState.Checked;
dG_List.Rows[e.RowIndex].Cells[6].Value = true;
}
}
}
}
}
private void dG_List_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (dG_List.IsCurrentCellDirty)
{
// Commit
dG_List.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
private void dG_List_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dG_List.Rows[e.RowIndex].Cells[6].ValueType == typeof(bool))
{
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dG_List.Rows[e.RowIndex].Cells[6] as DataGridViewCheckBoxCell;
chk.ThreeState = true;
}
}
- DataGridView 添加checkBox
- DataGridView 添加checkbox
- DataGridView 添加checkbox
- DataGridView 添加checkbox
- DataGridView 添加checkbox
- DataGridView如何添加CheckBox?
- DataGridView列中添加CheckBox
- dataGridView 单元格添加combox checkbox
- DataGridView中添加CheckBox控件主…
- Winform中 DataGridView添加 CheckBox列的问题集锦
- winform 中 给DataGridView的表头添加CheckBox
- DataGridView中添加CheckBox控件主要采用两种方法
- winform 中 给DataGridView的表头添加CheckBox
- 给 winform datagridview 头部 添加 checkbox 全选控件
- WinForm DataGridView CheckBox
- datagridview checkbox控件
- datagridview Checkbox实时更新
- datagridview Checkbox 仿radiobutton
- TinyXML:一个优秀的C++ XML解析器
- java的Comparator和Comparable
- OA发展趋势
- java调用(c+opencv)的DLL
- java复制文件的一种方法
- DataGridView 添加checkBox
- windows 多线程编程的几点经验 (防止死锁)
- Linux--根文件系统的挂载过程分析
- 存储过程1
- 写宏遇到的问题:warning: backslash and newline separated by space - C
- Spring Autowire自动装配
- C++和C#编写调用COM组件
- Struts2的声明式异常处理
- FARPOINT 常见用法