我想达到点击BUTTON就重绘DATAGRIDVIEW这个功能,(EXCEL里合并单元格的功能)
现在需要在
private void button1_Click(object sender, EventArgs e)
事件里执行
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
事件1.不知道代码怎么写?请高手赐教
2.或者有其他更好的方法?
现在需要在
private void button1_Click(object sender, EventArgs e)
事件里执行
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
事件1.不知道代码怎么写?请高手赐教
2.或者有其他更好的方法?
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
事件的内容
写成一个方法
public void ddd()
{}
然后两个同时调用它
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex != -1 && e.RowIndex != -1)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
}
}就这么个简单的事件,你可以试试三楼的方法更可笑
你是要我构造一个DataGridViewCellPaintingEventArgs么四楼的方法正在研究,多谢
使 DataGridView 中的某个单元格无效,并强制对它进行重新绘制。
// Force the cell to repaint itself when the mouse pointer enters it.
protected override void OnMouseEnter(int rowIndex)
{
this.DataGridView.InvalidateCell(this);
}// Force the cell to repaint itself when the mouse pointer leaves it.
protected override void OnMouseLeave(int rowIndex)
{
this.DataGridView.InvalidateCell(this);
}