DataGridView - Collapsed Rows by code

0
0

Hi

I have a block of rows that I want to be collapsed when the DataGrid opens for the first time …

But is not working with  sr1.Rows[lastLine].Collapse() even with sr1.Rows[lastLine].CollapseAll()

 

Is this the correct aproach for it ?

How do I collapse a group of rows bt code

 

lastLine++;
sr1.Rows[lastLine].HeaderCell.Style = headerStyleY;
sr1.Rows[lastLine].HeaderCell.Value = “Multiples “;
sr1.Rows[lastLine].MinimumHeight = 25;
sr1.Rows[lastLine].Height = 25;
sr1.Rows[lastLine].Tag = “S”;
sr1.Rows[lastLine].IsParent = true;
sr1.Rows[lastLine].Collapse();

sr1.Rows[lastLine].ReadOnly = true;

parentLine = lastLine;

lastLine++;
sr1.Rows[lastLine].HeaderCell.Style = headerStyle;
sr1.Rows[lastLine].HeaderCell.Value = “Net Debt/Ebitda “;
sr1.Rows[lastLine].ParentRow = sr1.Rows[parentLine];
sr1.Rows[lastLine].ReadOnly = true;

lastLine++;
sr1.Rows[lastLine].HeaderCell.Style = headerStyle;
sr1.Rows[lastLine].HeaderCell.Value = “Earnings/Share “;
sr1.Rows[lastLine].ParentRow = sr1.Rows[parentLine];
sr1.Rows[lastLine].ReadOnly = true;

 

Regards

Marcelo Blank

 

  • You must to post comments
0
0

Collapse the row after having added the child rows.

Don’t need to set IsParent = true when assigning child rows. That flag makes a row look like a parent row when it doesn’t have any child row loaded and lets you implement lazy loading: add child rows when the row is expanded.

You can use either Collapse() or CollapseAll() to collapse also child parent rows.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.