Hello,
I have a grid where there is a main row and child row. Users can configure what column go in what row (either parent or child) and can also set the order.
What is the best way to find a cell in the afterupdatemethod? I have been doing a set of if statements sort of like
if (e.cell.row.hascell("unitcost"))
do something
else
{
if(e.cell.row.band.index == 0)
if(e.cell.row.childbands[0].rows[0].cells.hascell("unitcost")
e.cell.row.parentrow.cells.etc.etc
Is there a better way?
Thanks.
Hi,
I'm afraid I do not understand what you are trying to do. What cell are you trying to find?
It could be any cell.
As an example: The grid represents a table that has the following:
unitcost, qty ,sell,extendedsell,description
Each row has a parent and child row. The user can configure the grid so that the columns can either be part of the parent or child row, such as:
parent: unitcost,qty,sell
child: extendedsell,description
When they change of the value of qty, I have code in the afterupdate event that updates the other sells such as extended sell. I don't know at design time where extended sell is (in the parent or the child) so I use code like shown above to see if the extended sell is in the parent or the child (taking into consideration that qty could be in either parent or the child). In the example below, dg is a class that has a decimal property for parsing.
dg.Parse = (
decimal)e.Cell.Row.Cells["mfgrlist"].Value;
(e.Cell.Row.Band.Index == 0)
decimal)e.Cell.Row.ChildBands[0].Rows[0].Cells["mfgrlist"].Value;
decimal)e.Cell.Row.ParentRow.Cells["mfgrlist"].Value;
So your tree control has a getnodebykey method, I was wondering if somewhere in the grid control there is a getcellbykey that can search both parent or child rows.