Back to Devexpress

DataGridView.EditorShowing Event

maui-devexpress-dot-maui-dot-datagrid-dot-datagridview-884b3081.md

latest3.2 KB
Original Source

DataGridView.EditorShowing Event

Fires when a cell editor is about to be displayed and allows you to cancel the action.

Namespace : DevExpress.Maui.DataGrid

Assembly : DevExpress.Maui.DataGrid.dll

NuGet Package : DevExpress.Maui.DataGrid

Declaration

csharp
public event EventHandler<EditorShowingEventArgs> EditorShowing

Event Data

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

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
FieldNameGets or sets the field name of the column for which the editor is about to be displayed. This is a bindable property.
ItemGets the data item that corresponds to the data grid item for which the editor is about to be displayed.
RowHandleGets the handle of the row that contains a cell for which the editor is about to be displayed.

Example

The code below shows how to prevent the Priority column from being edited if an item was sent more than a month ago.

xaml
<dxg:DataGridView x:Name="dataGridView"
                  Grid.Row="1"
                  EditorShowMode="Tap"
                  EditorShowing="dataGridView_ShowingEditor"
                  ItemsSource="{Binding Path=OutlookData}"
                  Tap="Handle_Tap"
                  ValidateCell="DataGridView_ValidateCell"
                  ValidationError="DataGridView_ValidationError">
    <dxg:DataGridView.Columns>
        <dxg:NumberColumn FieldName="Id" Width="70" IsReadOnly="true"/>
        <dxg:ComboBoxColumn FieldName="Priority" MinWidth="120"/>
        <dxg:TextColumn FieldName="From.Name" Caption="From" MinWidth="150" ClearIconVisibility="Auto"/>
        <dxg:DateColumn FieldName="Sent" Width="110"/>
        <dxg:TimeColumn FieldName="Time" Width="100"/>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
csharp
using DevExpress.Maui.DataGrid;

private void dataGridView_ShowingEditor(object sender, EditorShowingEventArgs e) {
    DataGridView dataGridView = sender as DataGridView;
    DateTime sent = (DateTime)dataGridView.GetCellValue(e.RowHandle, "Sent");
    if (e.FieldName == "Priority" && sent < DateTime.Now.AddDays(-30))
        e.Cancel = true;
}

See Also

DataGridView Class

DataGridView Members

DevExpress.Maui.DataGrid Namespace