DataGridView覆盖我的自定义行绘画 [英] DataGridView overrides my custom row painting

查看:194
本文介绍了DataGridView覆盖我的自定义行绘画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循MSDN上的示例,该示例使用RowPrePaint事件自定义绘制我的行.

I'm following the example on MSDN for using the RowPrePaint event to custom paint my rows.

http ://msdn.microsoft.com/zh-CN/library/system.windows.forms.datagridview.rowprepaint(v = vs.110).aspx

我只想自定义绘制一些行,而不是全部.我还应用了交替的行样式.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆