读书人

C#在一个事件里执行另一个事件的有关问

发布时间: 2012-02-13 17:20:26 作者: rapoo

C#在一个事件里执行另一个事件的问题
我想达到点击BUTTON就重绘DATAGRIDVIEW这个功能,(EXCEL里合并单元格的功能)
现在需要在
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()
{}
然后两个同时调用它

[解决办法]
按楼上的办法
独立出来写个方法
大家都可以调用
[解决办法]
dataGridView1_CellPainting(new object(),new DataGridViewCellPaintingEventArgs());
[解决办法]
试试dataGridView1.Invalidate()方法.
[解决办法]
话我不想多说 楼主快点节贴给分
这年头给分的越来越少了
[解决办法]
jf
[解决办法]
其实有一个更接近的方法楼主可以用:

DataGridView.InvalidateCell 方法
使 DataGridView 中的某个单元格无效,并强制对它进行重新绘制。
[解决办法]
dataGridView1.invalidate()方法,

来晚了。

读书人网 >C#

热点推荐