Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Merged cells by handling DataGridView.Paint smears when scrolled
 

Merged cells by handling DataGridView.Paint smears when scrolled

Year |2007

Month|1 | |2 |3

Week |1 |2 |3 |4 |5 |6 |7 |8 |9 |10

I have used the DataGridView.Paint event to make the top 2 rows appear as if their cells span the necessary months and weeks as shown above.

The problem is, when I scroll (using the DataGridView scrollbars), the content of the top 2 rows smear and the text flows together.

How can I avoid the smear when scrolling?

Gorlist  Tuesday, March 25, 2008 8:40 AM

HiGorlist,

You can handle the Scroll event of the DataGridView and force the cell to repaint by calling the InvalidateCell method. Here is a sample for your reference.

Let me know if this helps. If not, could you please provide more detailed information? Some code would be helpful.

Best regards.
Rong-Chun Zhang

Rong-Chun Zhang  Monday, March 31, 2008 3:27 AM

HiGorlist,

You can handle the Scroll event of the DataGridView and force the cell to repaint by calling the InvalidateCell method. Here is a sample for your reference.

Let me know if this helps. If not, could you please provide more detailed information? Some code would be helpful.

Best regards.
Rong-Chun Zhang

Rong-Chun Zhang  Monday, March 31, 2008 3:27 AM

Hi Rong-Chun,

That is exactly what I needed!

This solved my problem:

Private Sub dgwEdit_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles dgwEdit.Scroll

dgwEdit.InvalidateRow(0)

dgwEdit.InvalidateRow(1)

End Sub

Thanks
Gorlist  Monday, March 31, 2008 5:34 AM

You can use google to search for other answers

Custom Search

More Threads

• Remote server unreachable error message
• Provided organisms too large
• I need help on TaskVision someone plz!
• ERROR INSTALLING TERRARIUM CLIENT...
• This project Is an Example of Bad exception handling!!!!
• Client found response content type of 'text/html-charset-ISO-8859-1' but expected 'text/Xml
• Data Synchronization
• Pocket TaskVision - where is it?
• Please help! Need help for passing variable from a combobox
• Weird Behaviour