Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Accessing Non-Public Members
 

Accessing Non-Public Members

I would like to know how can I get access to the Non-Public members of a class.

I am trying to improve the performance (efficiency) of the CellPainting event for the DataGridView control. From a little experimentation, I have discovered that the CellPainting event fires for cells that do not require updating. I am using DataGrids that can take up the entire display of a 19" Wide display and sometimes only a few cells need updating yet depending on the location of those cells, many more cells are repainted unnecessarily.

Please refer to my other post for a deeper explanation: "DataGridView Performance Issue".
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/8e7ff594-bbf4-4abd-b494-796baf7f52d1/

So if anyone knows, how can I get access to the CellPaintingEventArgs of the DataGridView cell I wish to update (repaint)?
Do I need to override the DataGridViewCellPaintingEventArgs myself?

I found this link:

http://www.koders.com/csharp/fid1DBCB1E079D023FE239DE7F27C34FAC67DA643AF.aspx?s=cdef%3Adatagridview#L34

But I don't know how to incorporate it into my project!

Help much appreciated.

john....
john1166  Sunday, September 20, 2009 7:39 AM

Hi,

Cell Paint event also happens you move your mouse over it and scroll. I don’t think this will most improve the performance if limit the cell paint event.

Virtual mode is designed for use with very large stores of data. If the data is too large, you’d better load page of data at a time. Hope this helps.

Virtual Mode in the Windows Forms DataGridView Control

http://msdn.microsoft.com/en-us/library/ms171622.aspx

Implementing Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control

http://msdn.microsoft.com/en-us/library/ms171624.aspx

Paging in a DatagridView

http://69.10.233.10/KB/miscctrl/Pagable_DatagridView.aspx

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Unproposed As Answer byjohn1166 Tuesday, September 29, 2009 8:57 AM
  • Proposed As Answer bydekurver Monday, September 28, 2009 10:01 PM
  •  
Ling Wang  Saturday, September 26, 2009 4:18 PM
Hi Ling,

Yes I am aware that the CellPainting event is fired for various other reasons including resizing, scrolling, uncovering parts of a control etc.....

Implementing Paging or Virtual mode on the datagrid does not make any difference as the data is not read from a database or list and needs to be evaluated on a response by response basis. By this I mean, only the values (cells) that have changed in value either directly or by a specific formula used gets updated. And on recent close inspection, I believe the ClipBounds property of the DataGridViewCellPaintingEventArgs actually determines which cells are repainted whether it's needed or not! As I have said in a few other posts, you may only need to update the contents of 2 cells, but depending on their locations, many more cells are included because of this ClipBounds property!

I am aiming to get access to the DataGridViewCellPaintingEventArgs, modify a few of its properties and call the CellPainting event directly if that is possible!

Thanks for trying!

john...


john1166  Tuesday, September 29, 2009 9:27 AM

You can use google to search for other answers

Custom Search

More Threads

• List Object-->BindingSource = But BindingNavigator wont work
• Filling a DataGrid as data comes in from the DB
• DataGridView with Unbound Columns
• Click events on datagrid
• Keydown in datagrid
• BindingComplete event isn't firing - why?
• Column Visiblitiy ?
• Auto Update Database on Editing DataGridView
• master/Detail problem
• Handling unique column constraint errors