TreeViewControl.GetActiveEditorNeedsKey Event
Allows you to specify whether the active editor responds to certain keystrokes.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v26.1.dll
Declaration
public event EventHandler<TreeViewGetActiveEditorNeedsKeyEventArgs> GetActiveEditorNeedsKey
Event Data
The GetActiveEditorNeedsKey event's data class is TreeViewGetActiveEditorNeedsKeyEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Column | Gets the column that contains the active editor cell. |
| Handled | Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs. |
| Key | Gets the key a user pressed to activate the editor. |
| Modifiers | Gets the modifier keys (Shift, Ctrl, and Alt) a user pressed to activate the editor. |
| NeedsKey | Gets or sets if the active editor processes the current keystroke. |
| OriginalSource | Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs. |
| RoutedEvent | Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs. |
| RowHandle | Gets the handle of the row that contains the active editor cell. |
| Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
| TemplateChild | Gets an in-place editor specified in a cell template. |
| Value | Gets the current value in the active editor. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
| OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
Remarks
Handle the GetActiveEditorNeedsKey event to prevent key conflicts between navigation keystrokes in the TreeViewControl and the active in-place editor. You can set the e.NeedsKey property to false within a GetActiveEditorNeedsKey event handler to prevent the current keystroke from being processed by the in-place editor.
Example: Enable Arrow Keys for an In-Place Editor
The following example allows a ListBoxEdit in-place editor to process Up and Down keystrokes:
<dx:ThemedWindow x:Class="TreeViewControlApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
Title="TreeViewControl Demo" Height="450" Width="600">
<dxg:TreeViewControl x:Name="tree"
ChildNodesPath="Employees"
TreeViewFieldName="Name"
GetActiveEditorNeedsKey="OnGetActiveEditorNeedsKey">
<dxg:TreeViewControl.EditSettings>
<dxe:ListBoxEditSettings ItemsSource="{Binding Items}" />
</dxg:TreeViewControl.EditSettings>
</dxg:TreeViewControl>
</dx:ThemedWindow>
private void OnGetActiveEditorNeedsKey(object sender, TreeViewGetActiveEditorNeedsKeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.Up || e.Key == System.Windows.Input.Key.Down)
e.NeedsKey = true;
}
Related Events
The TreeViewControl fires the following events to process user actions that activate an in-place editor:
- GetIsEditorActivationAction
- Allows you to specify an action (key down, text input, or left mouse button click) to activate the focused editor.
- ProcessEditorActivationAction
- Allows you to specify whether the focused node should process an editor activation action.