DataGridView覆盖我的自定义行绘画 [英] DataGridView overrides my custom row painting
问题描述
我正在遵循MSDN上的示例,该示例使用RowPrePaint事件自定义绘制我的行.
I'm following the example on MSDN for using the RowPrePaint event to custom paint my rows.
我只想自定义绘制一些行,而不是全部.我还应用了交替的行样式.
I only want to custom paint some rows, not all. I also have an alternating row style applied.
当我逐步通过调试器时,我能够根据MSDN中的示例观察程序绘制的行(细微的渐变),但是,一旦RowPrePaint事件处理程序返回,程序就会根据其默认样式重新绘制该行.
When I stepped through the debugger I was able to watch the program paint the row according to the example in MSDN (a subtle gradient), but as soon as the RowPrePaint event handler returned the program repainted the row according to its default styles.
如何保持我的自定义绘画风格?
How can I keep my custom painting style?
推荐答案
设置DataGridViewRowPrePaintEventArgs.Handled = true
void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
e.Handled =true;
}
这篇关于DataGridView覆盖我的自定义行绘画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!