문제

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?

도움이 되었습니까?

해결책

Set the DataGridViewRowPrePaintEventArgs.Handled = true

void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
    e.Handled =true;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top