We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

CurrentCell.MoveTo After Inserting Row

After inserting a row in my databound grid I am trying to move the current cell back one line into the current cell. Although I am inserting a blank record into the data, after the current cell is moved, the data from the previous currentcell shows in my new currentcell. However, if I then move off the new currentcell and then back it shows up blank like it should. The code I''m using follows. How can I prevent this from happening? Public Sub insertRow() Dim row As Integer = m_grid.CurrentCell.RowIndex Dim col As Integer = m_grid.CurrentCell.ColIndex dtaProducts.GenProductsCollection.Insert(row - 1, New CGenProductsPricingInfo) m_grid.CurrentCell.MoveTo(row, col) End Sub

4 Replies

AD Administrator Syncfusion Team October 14, 2004 03:14 PM UTC

You will not be able to insert rows into a datatable. You can only add them at the end using DataTable.AddNew. If you need to rearrange the rows, then you can try to set up a DataView ordered on some hidden field that makes the rows appear in the order that you want them. But this will take some work to do.


JL Jeff Lancaster October 14, 2004 03:44 PM UTC

Actually, I am able to insert rows, as I am not bound to a datatable, I am bound to a custom collection implementing iBindingList. I have an insert function which works, it inserts a blank record and the grid is automatically syncing and properly showing the new blank record in the right row. The problem is, when I use the CurrentCell.Moveto, so as to reposition the highlighter into the new row, it appears to be displaying the data from the old current cell in the new one. If I click off the new current cell and then back on it displays properly.


AD Administrator Syncfusion Team October 14, 2004 05:07 PM UTC

Before you insert the row, try calling this.grid.CurrentCell.EndEdit() to see if this handles thie problem.


JL Jeff Lancaster October 14, 2004 05:15 PM UTC

Thanks Clay, that worked.

Loader.
Live Chat Icon For mobile
Up arrow icon