日期:2014-05-20  浏览次数:20780 次

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()方法,

来晚了。