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

Move row and current cell

I am having some issue with moving a row and trying to keep the current cell on the same cell in the new row. I am calling the CurrentCell.MoveTo method with the flag set to SetFocus. When I trace thru it appears to move the CurrentCell to the new row. However when the PrepareViewStyleInfo method is called the current row is back to the previous one. I rely on this code to change the highlighting and expand the current row. All subsequent code points to the current cell being back where it was before the move. However right after I call the move to the current cell is correct? Any ideas.

6 Replies

AD Administrator Syncfusion Team June 6, 2003 12:44 PM UTC

The e.RowIndex from the PrepareViewStyleInfo eventargs may or may not point to the current row. It points to the row of the cell that is about to be drawn. When you move from one row to another, it is likely both rows may need to be painted for some reason or the other. If you want to get the current row in PrepareViewStyleInfo, then you should use grid.CurrentCell.RowIndex. Is this how you are getting the currentrow?

AD Administrator Syncfusion Team June 6, 2003 12:47 PM UTC

Try also to to set RefreshCurrentCellBehavior.RefreshRow That will force the whole row to be repainted when moving to a new row. Stefan

CC Charles Carlin June 6, 2003 01:10 PM UTC

Maybe I confused the issue by keying in on PrepareView... The grid controls (non-databound) currentcell.rowindex property is changed to the correct value immediately after the call, however in prepareview and any other methods called afterwards the currentcell.rowindex is back to the old row. So if I trap in anywhere else (mousemove, currentcellmoving, etc) the currentcell is no longer correct.

CC Charles Carlin June 6, 2003 01:17 PM UTC

Now I am really confused because when I move row 4 up to row 3 and set row 3 active, row 4 remains active (after the initial call). However if I move row 4 to row 1 then row 2 becomes the current row. Similarly if I move row 1 to row 4 then row 3 becomes active. There definitely seems to be some type of off by one error here. It seems if I move a row up then the current row will equal one more then what I set it to and if I move it down it will equal one less?

AD Administrator Syncfusion Team June 6, 2003 02:26 PM UTC

The column header row is row zero, and the first 'regular' row is row 1. Can you attach a little project here showing this problem, or submit a Direct Trac support incidence with a sample?

CC Charles Carlin June 6, 2003 04:13 PM UTC

Well I figured it out, not really why but what caused it and how to do it properly. I was calling: gridControl1.Model.Rows.MoveRange(row, 1, nInsertAt); Which then raised the event for rowsmoving which was where I was trying to set the currentcell. I moved that code out of the rowsmoving event and placed it directly after the call to moverange and it works fine.

Live Chat Icon For mobile
Up arrow icon