public partial class SfDataGridPage : ContentPage
{
int currentRowIndex = -1;
public SfDataGridPage()
{
InitializeComponent();
dataGrid.CurrentCellBeginEdit += DataGrid_CurrentCellBeginEdit;
}
private async void DataGrid_CurrentCellBeginEdit(object sender, GridCurrentCellBeginEditEventArgs args)
{
await Task.Delay(100);
var row = dataGrid.GetRowGenerator().Items.FirstOrDefault(x => x.RowIndex == args.RowColumnIndex.RowIndex);
currentRowIndex = args.RowColumnIndex.RowIndex;
var column = (row.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "VisibleColumns").GetValue(row) as List<DataColumnBase>).FirstOrDefault(x => x.ColumnIndex == args.RowColumnIndex.ColumnIndex);
if (((column as IElement).Element as ContentView).Content is Entry)
{
(((column as IElement).Element as ContentView).Content as Entry).Completed += Entry_Completed;
}
}
private async void Entry_Completed(object sender, EventArgs e)
{
dataGrid.EndEdit();
await Task.Delay(500);
this.dataGrid.SelectedIndex = currentRowIndex + 1;
}
} |