Share via


Form.PageCount Proprietà

Definizione

Restituisce il numero di pagine nel form, una volta terminata la paginazione del form. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni per dispositivi mobili ASP.NET, vedere App per dispositivi mobili & Siti con 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

Valore della proprietà

Numero di pagine nel form una volta terminata la paginazione del form.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come usare la PageCount proprietà del Form controllo. Questo esempio di codice fa parte di un esempio più grande per la ControlToPaginate proprietà.

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

Commenti

Il Form controllo espone la proprietà e la PageCountCurrentPage proprietà, che forniscono informazioni su come viene impaginato il modulo corrente. La PageCount proprietà consente inoltre di fornire funzionalità di spostamento a un'altra pagina. Ad esempio, quando si esegue il rendering in un dispositivo più ricco, un modulo dei risultati della ricerca può includere elementi dell'interfaccia utente specifici del dispositivo che consentono all'utente di passare a una pagina di risultati in base al numero anziché alla navigazione dei collegamenti.

Nota

Questo valore è disponibile dopo che si è verificato l'evento Paginated . Per ottenere la proprietà, è possibile gestire l'evento PageCountPaginated del modulo.

Si applica a

Vedi anche