4 Replies - 5532 Views - Last Post: 08 October 2012 - 10:32 AM Rate Topic: -----

#1 diorno  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 18-September 12

Expand/Collapse rows in datagrid?

Posted 08 October 2012 - 07:54 AM

Hi all...!!!

Can somebody, explain me how to create e button in Datagrid for each row with the function to Expand/Collapse when it is clicked.

I want to show some data for the row where the button is clicked.

Thank you, all...!!!
Is This A Good Question/Topic? 0
  • +

Replies To: Expand/Collapse rows in datagrid?

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1606
  • View blog
  • Posts: 5,163
  • Joined: 25-September 09

Re: Expand/Collapse rows in datagrid?

Posted 08 October 2012 - 07:59 AM

Not sure I understand exactly what you mean but from what I gather, the following question arises.

If a button is in a row and you click it and shrink the row, how would you click said button to open the row back up? Or am I completely misunderstanding the question?
Was This Post Helpful? 1
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1606
  • View blog
  • Posts: 5,163
  • Joined: 25-September 09

Re: Expand/Collapse rows in datagrid?

Posted 08 October 2012 - 08:18 AM

OK, I guess after playing around with this, the row height shrinks to 3 which still leave it clickable

You could check to see if the CurrentRow.Height is > 3 and if so, set it to 3 else set it to 22 (or whatever height you start with).

You still end up with a row that looks like this:
Attached Image
Meaning you should probably do something with the background color so that it's apparent that it is a shrunken row. Plus it's not readily apparent that you can click that button in the row to open it back up.
Was This Post Helpful? 0
  • +
  • -

#4 diorno  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 18-September 12

Re: Expand/Collapse rows in datagrid?

Posted 08 October 2012 - 10:09 AM

Hello my friend, thanks for your reply...!!!

What i want to do is:
Assume i have a GridDataView with all the Clients.
I want for each client to add a button.
When the button is clicked i want to show for example all the information for that client.

Something like in a database:
If we click the triangle in the left side near the tables it shows all the tables of the database.

I am uploading a screenshot...!!!

I like what you show to me, but i want to show the button automatically for is row on page load.
And can you please give me some sample code?

Thank you...!!!
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3643
  • View blog
  • Posts: 11,405
  • Joined: 05-May 12

Re: Expand/Collapse rows in datagrid?

Posted 08 October 2012 - 10:32 AM

I assume that you are truly talking about the DataGrid and not the DataGridView.

If you are using the ASP.NET DataGrid, this article is for you: http://msdn.microsof...e/cc164077.aspx

If you are using the WinForms DataGrid, I've been told that the same techniques apply, but I've never really tried it out.

If you are talking about the WinForms DataGridView, check out this CodeProject where he does a lot of work to get the grouping feature to work: http://www.codeproje...items-in-Outloo

There are also commercially available options. I've gotten the impression that the Infragistics controls is the pack leader, but one of the major advertisers for DIC is DevExpress, and they also offer a hierarchical data grid control.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1