Form.PageCount Właściwość

Definicja

Zwraca liczbę stron w formularzu po utworzeniu formularza z podziałem na strony. Ten interfejs API jest nieaktualny. Aby uzyskać informacje o sposobie tworzenia aplikacji mobilnych ASP.NET, zobacz Mobile Apps & Sites with ASP.NET (Aplikacje mobilne & z ASP.NET).

public:
 property int PageCount { int get(); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public int PageCount { get; }
[<System.ComponentModel.Bindable(false)>]
[<System.ComponentModel.Browsable(false)>]
member this.PageCount : int
Public ReadOnly Property PageCount As Integer

Wartość właściwości

Liczba stron w formularzu po utworzeniu formularza jest podzielony na strony.

Atrybuty

Przykłady

W poniższym przykładzie kodu pokazano, jak używać PageCount właściwości kontrolki Form . Ten przykład kodu jest częścią większego przykładu ControlToPaginate dla właściwości.

void Form_Paginated(object sender, EventArgs e)
{
    // Set the background color based on 
    // the number of pages
    if (ActiveForm.PageCount > 1)
        ActiveForm.BackColor = Color.LightBlue;
    else
        ActiveForm.BackColor = Color.LightGray;

    // Check to see if the Footer template has been chosen
    if (DevSpec.HasTemplates)
    {   
        System.Web.UI.MobileControls.Label lbl = null;
        
        // Get the Footer panel
        System.Web.UI.MobileControls.Panel pan = Form1.Footer;

        // Get the Label from the panel
        lbl = (System.Web.UI.MobileControls.Label)pan.FindControl("lblCount");
        // Set the text in the Label
        lbl.Text = "Page #" + Form1.CurrentPage.ToString();
    }
}
Private Sub Form_Paginated(ByVal sender As Object, _
    ByVal e As EventArgs)
    
    ' Set the background color based on 
    ' the number of pages
    If ActiveForm.PageCount > 1 Then
        ActiveForm.BackColor = Color.LightBlue
    Else
        ActiveForm.BackColor = Color.LightGray
    End If
    
    ' Check to see if the Footer template has been chosen
    If DevSpec.HasTemplates Then
        Dim lbl As System.Web.UI.MobileControls.Label
        
        ' Get the Footer panel
        Dim pan As System.Web.UI.MobileControls.Panel = Form1.Footer

        ' Get the Label from the panel
        lbl = CType(pan.FindControl("lblCount"), System.Web.UI.MobileControls.Label)
        ' Set the text in the Label
        lbl.Text = "Page #" + Form1.CurrentPage.ToString()
    End If
End Sub

Uwagi

Kontrolka Form uwidacznia PageCount właściwość i CurrentPage właściwość, która udostępnia informacje o tym, jak bieżący formularz jest podzielony na strony. Właściwość PageCount pomaga również zapewnić możliwość nawigacji na innej stronie. Na przykład podczas renderowania na bardziej rozbudowanym urządzeniu formularz wyników wyszukiwania może zawierać elementy interfejsu użytkownika specyficzne dla urządzenia, które umożliwiają użytkownikowi przeglądanie strony wyników według liczby, a nie nawigacji linków.

Uwaga

Ta wartość jest dostępna po wystąpieniu Paginated zdarzenia. Aby uzyskać PageCount właściwość, możesz obsłużyć Paginated zdarzenie formularza.

Dotyczy

Zobacz też