Form.PageCount 屬性

定義

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

C#
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public int PageCount { get; }

屬性值

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

屬性

範例

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

C#
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();
    }
}

備註

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

注意

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

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

另請參閱