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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Always keep one selected row

Thread ID:





132377 Aug 29,2017 01:11 PM UTC Aug 30,2017 07:17 PM UTC Xamarin.Forms 1
Tags: SfDataGrid
Yossef Zaig
Asked On August 29, 2017 03:30 PM UTC


Xamarin Forms + SyncFusion Grid, Version, The tests are on UWP application

I am adding / updating / deleting rows of grid using source code, updating the grid itemsource in the viewmodel

After I add new row to the Grid, I select the new row as selected, this works ok
After I delete a row I want that the row after the deleted row will be selected, and if it was the last I want the row before deleted row to be selected, how can I do it ?

I have found that there is a problem setting SelectedIndex to the next or previous deleted row, only if I first set the SelectedIndex to other row (not near to the deleted row) and than set SelectedIndex to the required row, it works, any idea why ?

BTW - The same problem appear on screen too, when trying to select the row with the mouse, I first need to select other row and than select the row that is now in the place of the deleted row.

Am I doing something wrong ?


Ashok N [Syncfusion]
Replied On August 30, 2017 07:17 PM UTC

Hi Yossef, 
Thanks for contacting Syncfusion support. 
You can achieve your requirement with help of SfDataGrid.SelectedIndex property and dataGrid.SelectionController.RefreshSelection method. Please refer the below code example, 
private void Select_Clicked(object sender, EventArgs e) 
    int selectedindex = dataGrid.SelectedIndex; 
    if(selectedindex == viewModel.OrdersInfo.Count) 
        viewModel.OrdersInfo.RemoveAt(viewModel.OrdersInfo.Count - 1); 
        dataGrid.SelectedIndex = selectedindex - 1; 
        viewModel.OrdersInfo.RemoveAt(selectedindex - 1); 
        dataGrid.SelectedIndex = selectedindex ; 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon