Back to Devexpress

DataGridView.SwipeItemShowing Event

mobilecontrols-devexpress-dot-xamarinforms-dot-datagrid-dot-datagridview-6bba437a.md

latest3.8 KB
Original Source

DataGridView.SwipeItemShowing Event

Fires when a swipe item is about to be shown when a user swipes a row from left to right or from right to left, and allows you to cancel the action.

Namespace : DevExpress.XamarinForms.DataGrid

Assembly : DevExpress.XamarinForms.Grid.dll

NuGet Package : DevExpress.XamarinForms.Grid

Declaration

csharp
public event SwipeItemEventHandler SwipeItemShowing

Event Data

The SwipeItemShowing event's data class is SwipeItemEventArgs. 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.
IsStartSwipeItemGets whether the processed swipe item is about to be displayed on the left side of a grid row.
ItemGets the data item that corresponds to the processed grid row.
RowHandleGets the processed row’s handle.
SwipeItemGets the swipe item that is about to be shown.

Example

In the markup below, the right-side swipe item is Reply. The code below shows how to prevent this item from showing if the sender’s email contains “donotreply”.

xaml
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding OutlookData}" SwipeItemShowing="grid_SwipeItemShowing">
    <dxg:DataGridView.StartSwipeItems>
        <dxg:SwipeItem Caption="Sender Info" BackgroundColor="#26a95e" Tap="OnShowCustomerInfo" />
    </dxg:DataGridView.StartSwipeItems>
    <dxg:DataGridView.EndSwipeItems>
        <dxg:SwipeItem Caption="Reply" BackgroundColor="#797bff" Tap="OnReply" />
    </dxg:DataGridView.EndSwipeItems>
    <dxg:DataGridView.Columns>
        <dxg:TextColumn FieldName="From.Email" Caption="From" Width="150">
            <dxg:TextColumn.Width>
                <OnIdiom x:TypeArguments="GridLength" Phone="110" Tablet="150"/>
            </dxg:TextColumn.Width>
        </dxg:TextColumn>
        <dxg:TextColumn FieldName="Subject" />
        <dxg:DateColumn FieldName="Sent" Width="150">
            <dxg:DateColumn.IsVisible>
                <OnIdiom x:TypeArguments="x:Boolean" Phone="false" Tablet="true"/>
            </dxg:DateColumn.IsVisible>
        </dxg:DateColumn>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
csharp
using DevExpress.XamarinForms.DataGrid;

private void grid_SwipeItemShowing(object sender, SwipeItemEventArgs e) {
    DataGridView dataGridView = sender as DataGridView;
    string from = (string)dataGridView.GetCellValue(e.RowHandle, "From.Email");
    if (from.Contains("donotreply") && !e.IsStartSwipeItem)
        e.Cancel = true;
}

See Also

DataGridView Class

DataGridView Members

DevExpress.XamarinForms.DataGrid Namespace