The requested page is not available for the requested platform. You are viewing the content for Default platform.

GridControl.SwipeButtonClick Event

Occurs when a swipe button is tapped.

Namespace: DevExpress.Mobile.DataGrid

Assembly: DevExpress.Mobile.Grid.v18.2.dll

Declaration

public event SwipeButtonEventHandler SwipeButtonClick
Public Event SwipeButtonClick As SwipeButtonEventHandler

Event Data

The SwipeButtonClick event handler receives an argument of the SwipeButtonEventArgs type. The following properties provide information specific to this event.

Property Description
ButtonInfo Gets an object that stores information about a swipe button.
RowHandle Gets the row handle.
SourceRowIndex Gets the index of the record in a data source to which the processed row corresponds.

Remarks

Important

This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.

After you add a swipe button to the grid (by adding a SwipeButtonInfo object to the GridControl.LeftSwipeButtons or GridControl.RightSwipeButtons collection), handle the SwipeButtonClick event to implement the button functionality.

You can also use the GridControl.SwipeButtonCommand property to define an action to be performed when a button is tapped.

Examples

This example shows how to extend the grid’s UI with additional buttons to be shown when an end-user swipes left to right, or right to left, over a data row – Swipe Buttons. To create a swipe button, add a SwipeButtonInfo object to the GridControl.LeftSwipeButtons or GridControl.RightSwipeButtons collection. Use this object's SwipeButtonInfo.Caption, SwipeButtonInfo.Width, SwipeButtonInfo.BackgroundColor and SwipeButtonInfo.TextColor properties to specify button appearance.

To assign a custom action to a button, handle the GridControl.SwipeButtonClick event. The GridControl.SwipeButtonShowing event allows you to specify when a swipe button should be visible.

In the example, two swipe buttons are created.

  • When an end-user swipes any data row left to right, the Day button is shown on the left side of the row. Tapping this button displays the day of the week when the corresponding order was made.

    GridControl_LeftSwipeButton

  • When an end-user swipes right to left, a data row which corresponds to an order that is already shipped (the value in the Shipped column is true), the Delete button is shown on the right side of the row. Tapping this button removes the corresponding data row.

    GridControl_RightSwipeButton

void OnSwipeButtonShowing(object sender, SwipeButtonShowingEventArgs e)
{
    if ((!(Boolean)grid.GetCellValue(e.RowHandle, "Shipped"))
        && (e.ButtonInfo.ButtonName == "RightButton"))
    {
        e.IsVisible = false;
    }
}

void OnSwipeButtonClick(object sender, SwipeButtonEventArgs e)
{
    if (e.ButtonInfo.ButtonName == "LeftButton")
    {
        DateTime orderDate = (DateTime)grid.GetCellValue(e.RowHandle, "Date");
        string orderDateDay = orderDate.ToString("dddd");
        DisplayAlert("Alert from " + e.ButtonInfo.ButtonName, "Day: " + orderDateDay, "OK");
    }
    if (e.ButtonInfo.ButtonName == "RightButton")
    {
        grid.DeleteRow(e.RowHandle);
    }
}
See Also