Skip to main content
A newer version of this page is available. .
Tab

ASPxCardView.FocusedCardIndex Property

Specifies the focused card.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public int FocusedCardIndex { get; set; }

Property Value

Type Description
Int32

The card index.

Remarks

Note

Set the ASPxCardViewBehaviorSettings.AllowFocusedCard property to true to allow users to focus cards in the ASPxCardView.

The FocusedCardIndex property specifies the currently focused card. Set this property to a new value to move focus to a card with the specified index on the current page. To focus the card on the required page, switch to this page and then move card focus as described in the example below:

protected void Button1_Click(object sender, EventArgs e)
{
    // Gets the visible index of the required card.
    int cardIndex = ASPxCardView1.FindVisibleIndexByKeyValue("OLDWO");
    if (cardIndex == ASPxCardView.InvalidCardIndex) return;
    if (!IsCardVisibleOnScreen(cardIndex))
    {
        // Switches to the page that contains the required card.
        GoToPage(cardIndex);
    }
    // Focuses the card with the specified index.
    ASPxCardView1.FocusedCardIndex = cardIndex;
}

bool IsCardVisibleOnScreen(int cardIndex)
{
    int startIndex = ASPxCardView1.PageIndex * ASPxCardView1.SettingsPager.PageSize;
    int endIndex = startIndex + ASPxCardView1.SettingsPager.PageSize;
    return cardIndex >= startIndex && cardIndex < endIndex;
}
void GoToPage(int cardIndex)
{
    ASPxCardView1.PageIndex = cardIndex / ASPxCardView1.SettingsPager.PageSize;
}

Concept

Focused Cards

Online Demo

ASPxCardView - Focused Cards

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FocusedCardIndex property.

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.

See Also