Home Forums WinForms controls Xceed Grid for WinForms AddingDataRow event with combination of un-/bound grid

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14525 |

    I’ve created a combination of bound and unbound grid.

    In the AddingDataRow event, which is called when the dataset is bound to the grid, im trying to fill the unbound cells with related information.

    This works for the first item which is added to the grid, as this item is the current item of the dataset (i presume). When the second item is added, i am still getting data from the first item in the dataset.

    This is the code i use in the AddingDataRow event

    [code]

    DataRowView curRowView = m_SerialViewBindingSource.Current as DataRowView;
    SerialViewDataSet.SerialRow curSerialRow = curRowView.Row as SerialViewDataSet.SerialRow;
    string Serial = curSerialRow.SerialNumber;
    [/code]

    Now, im in doubt if this is normal behaviour, or that, somehow, i can know which row in the dataset is being accessed by the gridcontrol.

    Thanks in advance, for any leads in the right direction!

    Imported from legacy forums. Posted by opicron (had 2385 views)

    User (Old forums)
    Member
    Post count: 23064

    In the AddingDataRow, you need to use the e.DataRow to read or write to the row currently loading :
    e.DataRow.Cells[ x ].Value = “something”;
    For accessing the source (dataset) of the current row, do it through the SourceObject :
    e.DataRow.SourceObject
    which would be equivalent to the DataRowView in your case.

    Imported from legacy forums. Posted by André (had 339 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks a load AndreC,

    After doing some casting I’ve been able to retrieve all datarows I need! You have been very helpfull. I’ll post the information here to make this thread complete.

    [code]

    // cast the SourceObject to an DataRowView
    DataRowView curSerialRowView = (DataRowView)e.DataRow.SourceObject;

    //retrieve the SerialRow from the DataRowView
    SerialViewDataSet.SerialRow currentSerialRow = curSerialRowView.Row as SerialViewDataSet.SerialRow;

    //retrieve child relation rows (casted from DataRow[])
    SerialViewDataSet.GuaranteeRow[] currentGuaranteeRow = (SerialViewDataSet.GuaranteeRow[])currentSerialRow.GetChildRows(“FK_Serial_Guarantee”);

    //now you have a system.array with the datarows

    [/code]

    I hope this helps others with the same kind of problem.

    Imported from legacy forums. Posted by opicron (had 3596 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.