Back to Devexpress

DataViewBase.GetActiveEditorNeedsKey Event

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-4a53a6e9.md

latest10.0 KB
Original Source

DataViewBase.GetActiveEditorNeedsKey Event

Allows you to specify whether an active editor responds to keys that a user presses.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event EventHandler<GetActiveEditorNeedsKeyEventArgs> GetActiveEditorNeedsKey
vb
Public Event GetActiveEditorNeedsKey As EventHandler(Of GetActiveEditorNeedsKeyEventArgs)

Event Data

The GetActiveEditorNeedsKey event's data class is GetActiveEditorNeedsKeyEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets or sets a grid column, for which an event has been raised. Inherited from EditorEventArgsBase.
HandledGets 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.
KeyGets a key an end-user presses.
ModifiersGets a value indicating which of the modifier keys (Shift, Ctrl, and Alt) is in a pressed state.
NeedsKeyGets or sets whether an active editor responds to a key an end user presses.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
RowHandleGets or sets the row handle, for which an event has been raised. Inherited from EditorEventArgsBase.
SourceGets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.
TemplateChildAn in-place editor specified in a cell template.
ValueGets the edit value stored in the editor, for which an event has been raised. Inherited from EditorEventArgsBase.

The event data class exposes the following methods:

MethodDescription
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

The following code sample shows how to make an editor respond to the Up and Down keys:

View Example: How to Specify Navigation in Custom Cell Editors

xaml
<dxg:GridControl ItemsSource="{Binding Items}">
    <dxg:GridColumn FieldName="Country"/>
    <dxg:GridColumn FieldName="City">
        <dxg:GridColumn.CellTemplate>
            <DataTemplate>
                <dxe:ListBoxEdit x:Name="PART_Editor" ItemsSource="{Binding RowData.Row.Cities}" />
            </DataTemplate>
        </dxg:GridColumn.CellTemplate>
    </dxg:GridColumn>
    <dxg:GridControl.View>
        <dxg:TableView GetActiveEditorNeedsKey="GetActiveEditorNeedsKey" />
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
private void GetActiveEditorNeedsKey(object sender, DevExpress.Xpf.Grid.GetActiveEditorNeedsKeyEventArgs e) {
    if (e.Column.FieldName == "City" && (e.Key == System.Windows.Input.Key.Up || e.Key == System.Windows.Input.Key.Down))
        e.NeedsKey = true;
}
vb
Private Sub GetActiveEditorNeedsKey(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.GetActiveEditorNeedsKeyEventArgs)
    If e.Column.FieldName = "City" AndAlso (e.Key = System.Windows.Input.Key.Up OrElse e.Key = System.Windows.Input.Key.Down) Then
        e.NeedsKey = True
    End If
End Sub

Process End User Actions

The GridControl provides the following events to process end user actions:

EventDescription
DataViewBase.GetIsEditorActivationActionAllows you to specify whether an action (key down, text input, or mouse left button click) activates the focused editor.
DataViewBase.ProcessEditorActivationActionAllows you to make the focused editor process an activation action.
DataViewBase.GetActiveEditorNeedsKeyAllows you to specify whether an active editor responds to keys that a user presses.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetActiveEditorNeedsKey event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-embed-a-richtextbox-into-grid-cells/CS/Window1.xaml#L52

xml
<dxg:GridControl.View>
    <dxg:TableView Name="view" GetActiveEditorNeedsKey="view_GetActiveEditorNeedsKey" ProcessEditorActivationAction="view_ProcessEditorActivationAction"/>
</dxg:GridControl.View>

how-to-specify-navigation-in-custom-cell-editors/CS/NavigationBehavior.cs#L10

csharp
AssociatedObject.ProcessEditorActivationAction += TableView_ProcessEditorActivationAction;
    AssociatedObject.GetActiveEditorNeedsKey += TableView_GetActiveEditorNeedsKey;
}

wpf-data-grid-embed-a-richtextbox-into-grid-cells/CS/obj/Debug/net8.0-windows/Window1.g.cs#L165

csharp
#line 52 "..\..\..\Window1.xaml"
this.view.GetActiveEditorNeedsKey += new System.EventHandler<DevExpress.Xpf.Grid.GetActiveEditorNeedsKeyEventArgs>(this.view_GetActiveEditorNeedsKey);

how-to-specify-navigation-in-custom-cell-editors/VB/NavigationBehavior.vb#L13

vb
AddHandler AssociatedObject.ProcessEditorActivationAction, AddressOf TableView_ProcessEditorActivationAction
    AddHandler AssociatedObject.GetActiveEditorNeedsKey, AddressOf TableView_GetActiveEditorNeedsKey
End Sub

See Also

Assign Editors to Cells

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace