|
<syncfusion:SfDataGrid x:Name="dataGrid"
Grid.Column="0"
AllowEditing="False"
SelectionMode="Single"
NavigationMode="Cell"
ColumnSizer="Star"
AutoGenerateColumns="False"
LiveDataUpdateMode="AllowDataShaping"
ItemsSource="{Binding UserDetails}"
ShowRowHeader="False">
|
|
public class GridSelectionControllerExt : GridCellSelectionController
{
public GridSelectionControllerExt(SfDataGrid datagrid)
: base(datagrid)
{
}
//overriding the ProcessKeyDown Event from GridSelectionController base class
protected override void ProcessKeyDown(KeyEventArgs args)
{
if (args.Key == Key.Enter)
{
KeyEventArgs arguments = new KeyEventArgs(args.KeyboardDevice, args.InputSource, args.Timestamp, Key.Tab) { RoutedEvent = args.RoutedEvent };
base.ProcessKeyDown(arguments);
//assigning the state of Tab key Event handling to Enter key
args.Handled = arguments.Handled;
return;
}
base.ProcessKeyDown(args);
}
}
// Select button to edit the first column of the grid.
private void Button_Click(object sender, RoutedEventArgs e)
{
int rowNumber = WaveformGalleryDataGrid.SelectedIndex;
int colIndex = WaveformGalleryDataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex;
if (rowNumber != -1 && colIndex == 0)
{
WaveformGalleryDataGrid.AllowEditing = true;
RowColumnIndex rowColumnIndex = new RowColumnIndex(rowNumber + 1, 0);
WaveformGalleryDataGrid.MoveCurrentCell(rowColumnIndex);
WaveformGalleryDataGrid.SelectionController.CurrentCellManager.BeginEdit();
// while navigating current cell to next row or cell, the CurrentCell event will be triggerd
WaveformGalleryDataGrid.SelectionChanging += WaveformGalleryDataGrid_SelectionChanging;
}
}
|