2X faster development
The ultimate WPF UI toolkit to boost your development speed.
In Excel, the current cell is navigated towards right for Tab key and down for Enter key within the selected region. You can also achieve the same requirement in the GridDataControl, but it doesn’t have a direct support. To achieve this, you need to wire the PreviewKeyDown event in ModelLoaded event to handle the key navigation and SelectionChanging event to clear the selection when the current cell is out of the selected region based on the condition with local variable. You can wire these events as shown in the following code example. C# The PreviewKeyDown event for the GridDataControl is wired from the ModelLoaded event as shown in the following code example. C# With the help of SelectionChanging event, you can clear the selection when the current cell is clicked outside the selected ranges like Excel as shown in the following code example. C# Now, you can change the navigation behavior of Enter key from right to down like Excel by using the EnterKeyBehaviour.MouseDown in GridDataControl as shown in the following code example. C# With the help of the AlphaBend selection, you can achieve the selection format like Excel as shown in the following code example. C# The above AlphaBend selection is displayed in the GridDataControl as shown in the following screenshot. Figure 1 : Default position of the current cell with in selected region You can get the ranges of selected region by using the SelectedRanges property in the GridDataControl. You need to check whether the current cell is maintained within that selected region or not. With the help of CurrencyManager, you can get the current cell’s row and column index in the GridDataControl as shown in the following code example. C# While pressing the Tab key, the next cell is automatically selected as a current cell and you can decide whether the current cell is inside or outside the selected region by comparing the above current cell row and column index with the SelectedRanges as shown in the following code example. C# Similarly, you can also check and handle navigation behavior when the Enter key is pressed as shown in the following code example. C# You can refer to the following sample link to navigate the current cell within the selected ranges of GridCell in WPF. Link |
2X faster development
The ultimate WPF UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.