Tab

ASPxCardView.FocusedCardIndex Property

Specifies the focused card.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public int FocusedCardIndex { get; set; }
Public Property FocusedCardIndex As Integer

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

See Also