如何将datagridview中的多个checkBox设置为单选
来源:互联网 发布:VB中Picture 编辑:程序博客网 时间:2024/06/17 02:08
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows.Count <= 0)
{
return;
}
bool a = (bool)dataGridView1.CurrentRow.Cells[1].EditedFormattedValue;
bool b = (bool)dataGridView1.CurrentRow.Cells[2].EditedFormattedValue;
bool c = (bool)dataGridView1.CurrentRow.Cells[3].EditedFormattedValue;
if (e.ColumnIndex == 1 && e.ColumnIndex != -1 && a == true)
{
dataGridView2.Rows.Clear();
dataGridView1.CurrentRow.Cells[2].Value = false;
dataGridView1.CurrentRow.Cells[3].Value = false;
}
if (e.ColumnIndex == 2 && e.ColumnIndex != -1 && b == true)
{
dataGridView1.CurrentRow.Cells[1].Value = false;
dataGridView1.CurrentRow.Cells[3].Value = false;
selectSLabelNo(dataGridView1.CurrentRow.Cells["Column1"].Value.ToString());
}
if (e.ColumnIndex == 3 && e.ColumnIndex != -1 && c == true)
{
dataGridView2.Rows.Clear();
dataGridView1.CurrentRow.Cells[1].Value = false;
dataGridView1.CurrentRow.Cells[2].Value = false;
}
if ((e.ColumnIndex == 1 || e.ColumnIndex == 2 || e.ColumnIndex == 3) && e.ColumnIndex != -1 && a == false && b == false && c == false)
{
dataGridView2.Rows.Clear();
dataGridView1.CurrentRow.Cells[1].Value = true;
dataGridView1.CurrentRow.Cells[2].Value = false;
dataGridView1.CurrentRow.Cells[3].Value = false;
}
}
其中cells[1].cells[2],cells[3]为三个checkBox选择框,然后为了美观,当鼠标up时,更改数据
private void dataGridView1_MouseUp(object sender, MouseEventArgs e)
{
dataGridView1.EndEdit();
}
- 如何将datagridview中的多个checkBox设置为单选
- DataGridView中的checkBox单选
- httpclient 如何设置多个checkbox
- DataGridView中CheckBox实现单选
- 多个checkbox实现单选的checkbox
- 如何将DataGridView转换为DataTable?
- Datagridview 中的checkbox 勾选状态失效
- DataGridView如何添加CheckBox?
- C# 如何为 datagridview 中增加checkbox列
- 将数据库表中的多个字段中的null设置为空串
- 如何将当前单元格始终设置为第一个单元格
- CheckBox的使用(四):ListView中的项设置为可以多选
- 如何将文字中的指定文字设置为段首
- 如何将dialog中的button动态设置为disable
- 设置GridCtrl中的Checkbox 为不可编辑
- 如何将SQL Server数据表中的数据按条件批量导出为多个Excel文件
- WinForm中,将DataGridView中的某一行某一列设置为下拉列表时候单独绑定数据源
- dataGridView中的反向选择, checkbox
- 基于遥感数据的地表蒸散量的获取与分析的解决方案
- 数组排序
- Android Volley完全解析(二),使用Volley加载网络图片
- DiskSim的安装过程(二)
- 你了解隆力奇吗
- 如何将datagridview中的多个checkBox设置为单选
- Debugging vs-android projects with VisualGDB
- MAC COCOA call command 调用终端控制台程序
- mysql无法启动
- maven plugin的execution出错
- 利用DHT网络原理制作bt采集蜘蛛,开源版
- 白银不孕不育医院哪里比较好
- UITableView headerView头视图的复用
- 暑期兼St语然后”哪