how to expand and collapse rows in DataGrid to create parent/childrelationships using a single table

F

Farshad Abasi

Hello al,

I am new to Windows Forms and for the past week or so, I have been
pulling my hair out, trying to figure out how I can implement
expand/collapse in the DataGrid.

I do understand that if I setup relations between two tables in a
dataset, and then assign the primary table to the DataGrid, I get the
+/- buttons and I can expand and collapse, but this is NOT what I want.

I don't have two tables. I have 1 table, where there are rows of data,
some of which are childern of other rows. This is indicated by a colum
in each row, which has the ID of the parent row.

There is a really good example of what I want to do here:

http://www.codeproject.com/aspnet/HierDataGrid.asp

Basically, this person (in the link above) has implemented EXACTLY what
I want to do, by adding a colum with the +/- buttons, and then hiding
all rows that are NOT supposed to be displayed and displaying those what
ARE supposed to be displayed, using the Visible property of the row in
the datagrid (setting it to true/false as needed).

I have looked all over the internet to try and find out how to do this
in Windows Forms DataGrid, have had no luck so far. Your help would be
GREATLY appreciated.

Cheers,

-farshad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top