how to embed child datagrid from its parent

Hi, All, posted a thread earlier regarding nested tables on .net data grid, guess, the simple goal that I am looking for is: for a .net datagrid on a win form app, how can I embed a child datagrid for each data row - so I can click one of the parent row column (e.g. first column of the parent data row and launch the embed child datagrid that loads details child lelev information  thanks.

mark


Answer this question

how to embed child datagrid from its parent

  • Edward Rose

    Thanks for the updates, BUT THIS IS NOT IT, having a related tables bound to the data set, it'll show up default "+" sign, BUT YOU STILL HAVE TO CLICK THE "+" to drill down the detailed data, what I am trying to do is, when clicking "+" sign, the detailes automatically showed up in the same window and behave like a embeded child datagrid, IF YOU USE Syncfusion Data Grid, they do the same stuff called hier- data datagrid, and just a FYI, since you built relation already, you can bound the grid to the tables[0] dirctly, what I am looking for here is a bit complicated than this, thanks.

    mark

  • Ekta

    Just so everyone knows, the best way I have found to do nested grids is with a custom column style

    I have this panel style with a little thumb tack in one column. When you press it, I show a panel, now in the panel could be any control, including a datagrid. If you do your relations right, then it will show the child records in that datagrid.

    Yea you still have something to click on, but it's alot better then the little plus sign. And you can still see the orginal datagrid in the background.

    Plus since it's a panel I can show text box controls to edit that column and it makes things so nice.

  • Dick Kuo

    check my previous post response and another thread called: "nested tables on a drill down datagrid !!
    "

  • amiga


    take a look at the following link:

    http://www.syncfusion.com/Products/grid/features/grid_feat_3.aspx

    and 

    http://www.syncfusion.com/Products/grid/features/grid_feat_2.aspx

    to implement this in datagrid on windows form application is far complicated than just binding related table to the grid, doing this on the web form is bit simple since the web form out is html - trick can be done in a extendable html block, and I AM LOOKING for a windows form based solution for .net datagrid that can function similar as above Syncfusion product.

    mark

  • Adithya reddy

    Why not just buy the Syncfusion grid if you want such a fancy control

    I don't think you'll ever get the intrinsic datagrid do embedded grids like that; maybe if you implement a custom version of the datagrid and override a lot of code... i'd really have to think about that, one but you might be able to make your own.  

    But short of creating your own customized DataGrid, the best you could do would be to create an onclick event for the grid that rebinds it to the related table.  You could use a context menu (or button, whatever) to navigate back.  But you're still only going to see one grid at a time.


  • Squall Leonhart

    Basically, you will select both tables into a single DataSet.  Then add a relationship to the DataSet that bind the two tables.  Now bind your datagrid data source to the dataset and the display member to the parent table.  The grid will automatically pull the relationship.

    EXAMPLE:

    I have 2 tables, [PressData] and [PartData].  [PressData] has a unique ID Field called [Number].  The [PartData] table has all the parts for a given press.  The [PartData] table has a field called [Press] that is the [Number] from the [PressData] table.  I want my DataGrid to display all the Press records and I want to expand an press record to show all the parts in that press.  I do the following:

    Add DataAdapter1 to the project.  Configure it to select all fields from [PressData].  

    Add DataAdapter2 to the project to select all fields from [PartData].  Use the DataAdapter to generate DataSet1 (be sure to select both tables in the dialog when creating the dataset).  

    Now your DataSet has both tables in it.  You just need to execute the following code when your form loads:

    DataAdapter1.Fill(DataSet1)
    DataAdapter2.Fill(DataSet1)

    DataSet1.Relations.Add(DataSet1.Tables("PressData").Columns("Number"), DataSet1.Tables("PartData").Columns("Press"))

    DataGrid1.SetDataBinding(DataSet1, "PressData")

    Thats it!!

  • turnkey

    Hi, if you check my original question - I mentioned "how to embed child data grid from its parent" - NOT "how to bind related tables together", so what I am looking for is "HOW TO EMBED child data grid to the bound parent level table" - as a matter of fact, it can be done through a customized data model / renderer ( view ), per .net and win form, this will be translated into "catching the clicking events on a given parent column and build a data grid on the fly to display the chold level data", I believe some on on microsoft sode already provided a solution for ASP.NET web control and lag on windows form side, and this is also why product like Syncfusion becomes so popular - Just try to correct your comments: YES, YOU CAN implements this using .NET datagrid, talking about whether .net DataGrid supports it or not, be very fankly, none of the functions that developer looks into are default from .NET data grid, it needs efforts anyway.

    mark

    >>>>

  • Octavio

    Hey, sorry that's not what you wanted, but it is the answer to your question.  That IS how you display two related tables in a .NET DataGrid.  You want functionality that the .Net DataGrid can't supply so you can't get the answer you're looking for.

    And thanks for the FYI, but had I posted the code showing a direct bind to the Table, it would not have been as clear how the bind to the relationship was actually taking place.  Shortcut code is not good example code.

    This is still an interesting request.  I would be interested in ideas about implementing a custom DataGrid to give it the functionality you are looking for.

  • Gregory Dye

    Also looking to do this in a windows app.

    Have you found a solution Mark

  • Bhanu_Prakash

    The good old flexgrid (com) can do that , so you maybe can do it with Com-interop if you realy need it.

    you could make something like a datagrid-datagridcolumn that show related data as you klik on it .

    Good luck 

    Remco

  • James Lapalme

    pls read my post in details
  • how to embed child datagrid from its parent