DataGridView overrides my custom row painting

ε祈祈猫儿з 提交于 2020-01-17 04:55:09

问题


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

http://msdn.microsoft.com/en-us/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.

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?


回答1:


Set the DataGridViewRowPrePaintEventArgs.Handled = true

void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
    e.Handled =true;
}


来源:https://stackoverflow.com/questions/22355180/datagridview-overrides-my-custom-row-painting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!