如何判断DataGridView是否被全选?(WinForm)
解决方案 »
- 无人解答 55555 关于自定义 wpf.richtextbox
- 判断pdf文件?
- treeview树节点右键弹出菜单后如何在菜单响应函数中知道是点击哪个节点弹出的菜单
- 小白问题--panel的Scroll事件
- 慕白兄请进?
- 关于JavaScript字符串替换问题
- 为什么我的VS2005中的工具的组件项下没有"windows media player"呢.
- WINCE 下关于异步委托调用的问题
- 怎么让textedit输入的值为正的,而且可以输如小数
- c#能不能让代码页显示行号?方便选中。c#有没有jbduildr的括号匹配提示?就是选择一个括号,系统回自动高亮与它匹配的括号?
- RichTextBox的Select(int begin,int length)问题,高手来指教下~
- 关于两个数据库的sql事务问题
{
foreach(DataRow row in dgv.Rows)
{
if(!row.Selected)
{
return false;
}
}
return false;
}
{
this.dataGridView1.SelectAll();
}
class DGVColumnHeader : DataGridViewColumnHeaderCell
{
private Rectangle CheckBoxRegion;
private bool checkAll = false; protected override void Paint(Graphics graphics,
Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
DataGridViewElementStates dataGridViewElementState,
object value, object formattedValue, string errorText,
DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{ base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value,
formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds); CheckBoxRegion = new Rectangle(
cellBounds.Location.X + 3,
cellBounds.Location.Y + 2,
25, cellBounds.Size.Height - 4);
if (this.checkAll)
ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Checked);
else
ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Normal); Rectangle normalRegion =
new Rectangle(
cellBounds.Location.X + 1 + 25,
cellBounds.Location.Y,
cellBounds.Size.Width - 26,
cellBounds.Size.Height); graphics.DrawString(value.ToString(), cellStyle.Font, new SolidBrush(cellStyle.ForeColor), normalRegion);
} protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)
{
//Convert the CheckBoxRegion
Rectangle rec = new Rectangle(new Point(0, 0), this.CheckBoxRegion.Size);
this.checkAll = !this.checkAll;
if (rec.Contains(e.Location))
{
this.DataGridView.Invalidate();
}
base.OnMouseClick(e);
} public bool CheckAll
{
get { return this.checkAll; }
set { this.checkAll = value; }
}
}
全选滴事件private void dgv_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
if (e.ColumnIndex == 0)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
dgv.Rows[i].Cells[0].Value = dgvColumnHeader.CheckAll;
}
}
}