Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3455
How can I insert a new row in a particular location
posted

Hi,

Is there a way to add a new row in a band at a particular position?

For example if I need to add the new row, above or below the selected row.

Regards,

Ceaser

Parents
No Data
Reply
  • 37774
    Suggested Answer
    posted

    Ceaser,

    This depends on your data source, in that you might be able to insert the row directly into the proper location in the underlying data source.  If you do this, you can get the index of the selected row by checking its ListIndex and then insert a row directly before that row in the data source.  If you are using a DataTable, however, there are issues where it will report the incorrect location of the new row to the grid.  If this is the case, you can move the row using the Move method on the Rows collection, specifying that you can move it to the new grid index before the selected row's Index, i.e.

    grid.Rows.Move(newRow, selectedRow.Index );

    -Matt

Children
No Data