开发者

DataGridView cells are not painted

I got a DataGridView which does not paint it content cells. The header are visible and can be resized. The vertical scrollbar is there and can be moved - so the rows are existing (when the source changes, the scrollbar updates correctly).

But the part where the cells should be 开发者_JS百科painted stays "unpainted" meaning you can see some of the effects when there is no refresh to part of a display. There are ghost of the background when you move the form and when you open the context menu and closes it, it graphic will remain in the "cell part" of the DataGridView.

Has anyone encountered this effect?


I was not able to provide a minimalistic example, so no code. Just hoped someone encountered the effect together with DataGridView.

Nevertheless I found the solution: I implemented the RowPrePaint event. When an exception occurs within the event handler the data grid silently catches it and simply does not paint. A try-catch-block by myself was all to do (and fix the source of the exception to improve my code of course).


I had this same problem with a DataGridView of my own. ZoolWay's self-answer gave me a push in the right direction. My problem was that I had a piece of code running in the Paint event for a custom DataGridViewCell that was referencing the cell's Value property. The property was not overridden properly, so the DataGridView quit after failing to draw one cell resulting in a blank, partly-seethrough control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜