winform DataGridView实现用shift多选checkbox
来源:互联网 发布:泰州网络推广 编辑:程序博客网 时间:2024/06/12 01:46
哈哈,谨以此文记住自己的一点笨方法
背景:winform,c#,Datagridview,checkbox 实现自由多选 保证DataGridview的MultiSelect属性值为true
代码中加入如下内容:
全局变量:
private int startrow = -1;
以下是Datagridview的两个事件:
private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
{
if (this.dataGridView1.SelectedCells.Count > 0 && e.KeyData == Keys.ShiftKey)
{
int endrow = this.dataGridView1.CurrentRow.Index;
if (startrow <= endrow)
{
//正序选时
for (int x = startrow; x <= endrow; x++)
{
this.dataGridView1.Rows[x].Cells["我的checkbox列"].Value = 1;
}
}
else
{
//倒序选时
for (int x = endrow; x <= startrow; x++)
{
this.dataGridView1.Rows[x].Cells["我的checkbox列"].Value = 1;
}
}
}
}
private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && !(Control.ModifierKeys == Keys.Shift ))
{
if (this.dataGridView1.Focused && this.dataGridView1.CurrentCell.OwningColumn.DataPropertyName == "checkbox" && Convert.ToBoolean(this.dataGridView1.CurrentCell.EditedFormattedValue) == false)
{
startrow = this.dataGridView1.CurrentRow.Index;
}
}
}
ok啦,希望有帮助!!!
- winform DataGridView实现用shift多选checkbox
- WinForm DataGridView CheckBox
- 实现DataGridView的按Shift多选
- winform中实现DataGridView的打印,用c#实现
- [WinForm]Datagridview 实现二维表头
- Winform中 DataGridView添加 CheckBox列的问题集锦
- winform 中 给DataGridView的表头添加CheckBox
- winform 中 给DataGridView的表头添加CheckBox
- 给 winform datagridview 头部 添加 checkbox 全选控件
- C#Winform判断DataGridView中的checkbox列是否选中
- C# Winform中DataGridView的DataGridViewCheckBoxColumn CheckBox是否选中
- DataGridView中CheckBox实现单选
- winform datagridview IList datasoure 实现排序
- WinForm下DataGridView导出Excel的实现
- C#WINFORM 的DATAGRIDVIEW多表头实现
- C#Winform:DataGridView 简单分页实现
- .NET Winform Datagridview 实现多行表头
- C# Winform DataGridView 公共分页实现
- 取出目录下面所有.java的文件
- hw去年上机题2
- [算法] 人工智能Java 坦克机器人系列
- vi 语法高亮
- 执行shell脚本中declare: not found
- winform DataGridView实现用shift多选checkbox
- Golden Gate
- Hibernate3错误:could not initialize proxy – no Session的解决办法
- ZeroMemory、memset 和 “={0}”的联系与区别
- 电话一面
- Android log扩展
- C#中调用非托管的DLL及参数传递
- 互联网产品设计进阶(16)灵活使用层布局页面
- Timer Elapsed