Share via


Form.PageCount 屬性

定義

在表單分頁後,傳回表單中的頁數。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites

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

屬性值

表單分頁後表單中的頁數。

屬性

範例

下列程式代碼範例示範如何使用 PageCount 控件的 Form 屬性。 此程式代碼範例是 屬性較大範例 ControlToPaginate 的一部分。

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

備註

控件 FormPageCount 公開 屬性和 CurrentPage 屬性,以提供目前窗體編頁方式的相關信息。 屬性 PageCount 也有助於將導覽功能提供給另一個頁面。 例如,在更豐富的裝置上轉譯時,搜尋結果窗體可能包含裝置特定的UI元素,可讓使用者依編號流覽至結果頁面,而不是透過連結流覽。

注意

發生事件之後 Paginated ,即可使用這個值。 若要取得 PageCount 屬性,您可以處理 Paginated 表單的事件。

適用於

另請參閱