add child row to a specific row in DataGrid

hamid

Centurion
Joined
Jul 13, 2004
Messages
114
i have a datagrid with some row and i want add new row to some of rows.
i want create group of rows together.
how can i add new row to specific row?
 
not sure I understand you entirely, so I will be brief.
you want to add data to a specific row in a data grid? (i.e. multiple lines of data)

If so, there are a number of ways to do this. you could have two datagrids that are linked by an event i.e.CurrentCellChanged (update the other datagrids dataset, and control them seperatly). Or, you could add another table to your data set, that your current datagrid is bound to. Then, setup a relationship between the two tables (parent > child). You can then drill into a specific row and add detail to the new table in your dataset. ???? not sure if that helps.
 
no!
i want add new row of my current datagrid and set itchild of specific row :(
did you see any datagrid with some plus icon near of rows that when you click on them, you can see its child rows?
that row number 2 have 3 child rows.

if you can think that this is a datagrid view:
Code:
[B]  Code   Name      ParentID[/B]
[COLOR=YellowGreen]  +1       name1     0[/COLOR]
[COLOR=Green]  -2       name2     0
      4     name4     2
      5     name5     2
      6     name6     2[/COLOR]
[COLOR=YellowGreen]  +3       name3     0[/COLOR]
[COLOR=Green]  +7       name7     0
[/COLOR]
:confused:
 
Sounds like you are talking about a recursive relationship. The only way I know of to get close to that, is similar to what I've already described (if you have only got two levels).

Have two identical tables(Elements) in your dataset, then set up a relationship between the two. i.e. TableB link ParentID field to TableA Code field. Then when you load the data for TableA put in the Where clause ParentID = 0, and for TableB ParentID<>0.

This should allow a drill down on your Datagrid to each of your top level codes and add data (even ones that don't currently have any child records). But, it is fairly static structure. If you intend to drill down further you will have to add extra tables(elements) to your dataset which may get a bit messy.

However, I've seen you can set up a internal relationship in your dataset between two fields in your table (element), i.e. ParentID and Code. so, if that works it theoretically should give you infinite levels. I’m fairly new to .NET and this isn't a problem i've tackled yet but hope it helps... :)
 
NO
this is very easy and many user use of this ability to have group rows in datagrid.
i just want to have some group rows in my datagrid!

:((
 
I think you might be confusing people with your description. You keeping talking about a datagrid, but if I'm understanding you correctly then what you are after isn't supported in a standard datagrid (as far as I know). It sounds to me like what your after is a hybrid of a datagrid and a treeview (thus allowing child nodes, as well as multiple columns). Perhaps one of the standard controls can achieve this, but if they can I've never come across it.
 
Back
Top