Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGrid Performance
 

DataGrid Performance

I've isolated a piece of code that is taking a large performance hit. It is simply the formatting in a datagrid.

With a datagrid having 511 rows, this section alone takes up about 40 seconds.

I would appreciate any suggestions that might increase performance.

Padding padding = this.datagrid.Rows[row].Cells[column].Style.Padding;

padding.Left = composite.indentation * margin;

this.datagrid.Rows[row].Cells[column].Style.Padding = padding;

this.datagrid.Rows[row].Cells[column].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;

this.datagrid.Rows[row].Cells[column].Style.WrapMode = DataGridViewTriState.False;

solardog  Thursday, August 20, 2009 7:05 PM
Thanks, I found the answer. The table had 500 rows and 13 columns or 6500 cells. The program was setting wrap for each cell and also setting alignment for each cell at runtime. The caused each of 6500 cells to be unessarily formatted twice, which required a lot of not needed processing.
solardog  Thursday, September 03, 2009 8:32 AM

Hi solardog,

According to your code, I think you are talking about DataGridView instead of DataGrid. Did you use databinding for the DataGridView?

Normally load 511 rows won’t cost long time. So I want to know how many columns are there in your table? Do you use DataTable/DataSet as the datasource? Could you please make a test to see how much time it cost to read 511 rows from database? (Do not bind it to the DataGridView when you test it)

Sincerely,

Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Monday, August 24, 2009 7:13 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Monday, August 31, 2009 1:53 AM
Thanks, I found the answer. The table had 500 rows and 13 columns or 6500 cells. The program was setting wrap for each cell and also setting alignment for each cell at runtime. The caused each of 6500 cells to be unessarily formatted twice, which required a lot of not needed processing.
solardog  Thursday, September 03, 2009 8:32 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView: programatically add new row for bound grid?
• Is there a way to tell when all the databindings are complete?
• DataBound Property Set is called twice
• BindingSource.Filter = "Like '%Item*32323%'";
• Image Column and DataGridView
• First VB trial and no joy
• Strange problem with DataGridViewComboBoxCell
• DatagridView problems getting data from Dataset
• ListBox selection problem
• Can't get ObjectDataSource Paging to work!