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
1655
Add a column at a particular index
posted

Hi,

I want to add a row to the grid at a particular row index. How can i do it?

Using XamDataGrid.DataItems.Add() will add the row to the bottom of the frid. I want to add the row, say at the second position.

 

Thanks

Varun

  • 69686
    posted

    Varun,

    You can use the Insert method of the DataItems collection to do this:

    this.dgDet.DataItems.Insert(1, employeeDet);

    For more flexibility, you can bind to grid to a collection(BindingList<T>) and manipulate it, instead of directly inserting items inside the XamDataGrid.

    BindingList<Employee> dataSource = new BindingList<Employee>();

    Hope this helps.

  • 9836
    posted

    Hi Varun,

    You can try the following :

    xamDataGrid1.DataItems.Insert(2, item);

    Hope this helps

    Vlad