hamid Posted May 3, 2006 Posted May 3, 2006 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? Quote [ once4ever ]
jch001 Posted May 3, 2006 Posted May 3, 2006 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. Quote
hamid Posted May 3, 2006 Author Posted May 3, 2006 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: [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: Quote [ once4ever ]
jch001 Posted May 3, 2006 Posted May 3, 2006 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... :) Quote
hamid Posted May 3, 2006 Author Posted May 3, 2006 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! :(( Quote [ once4ever ]
Cags Posted May 3, 2006 Posted May 3, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.