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

SelectionChanging Event and CurrentCell.MoveTo()

Hi, I am using GridDataBoundGrid. The dataGrid's Model.SelectionChanging event is tied to a method that tries to verify if the existing data has been updated to prompt the user to save. When a new item is inserted to the grid, a new row is added and I use the CurrentCell.MoveTo() to highlight the new row. In certain cases, even though the CurrentCell.RowIndex is shown to be updated, the highlight is not. Also, the SelectionChanging event doesn't even fire as it should be. I would like to know mainly what needs to be done to make sure the selection to update. I also have a CurrentCellActivating handler. The CurrentCellActivating handler does fire everytime... Thanks for the assistance.

3 Replies

AD Administrator Syncfusion Team October 17, 2003 09:22 PM UTC

SelectionsChanging is a event that fires where the user drags the mouse to select cells. Is this the action you want to catch to verify data? Maybe you need to use either the CurrentCellValidating or the CurrentCellMoving events. These events fire when the user makes a change and then tries to leave the current cell, or when the user just tries to move the current cell respectively.


CC Charlies Chan October 20, 2003 01:45 PM UTC

Thanks for your help Clay. Unfortunately, I think I might not have been clear with my question. Let me try to rephase it again. Basically, I have a GDBG. I add an item to the end of the list. I then call CurrentCell.MoveTo() to move the focus last item in the list. The last item in this list is highlighted. Now I click on another item in the list (e.g. 3rd item). I click Add again, another item is being inserted into the list. Again, CurrentCell.MoveTo() is called inside the same function. Now when I check CurrentCell.RowIndex, it gives me the correct/last row in the list. Yet this row is somehow not highlighted. The highlight is still at the 3rd row I selected previously. If I now click on the last row, the highlight will follow. How can I make MoveTo() highlight the last row? Thank you.


AD Administrator Syncfusion Team October 20, 2003 02:25 PM UTC

Make sure the grid has focus when you try this. Also you can try explicitly selecting the lastrow after your call to MoveTo. grid.Focus(); grid.CurrentCell.MoveTo(lastRow, someCol); grid.Selections.Clear(); grid.Selections.Add(GridRangeInfo.Row(lastRow));

Loader.
Live Chat Icon For mobile
Up arrow icon