Form.PageCount Свойство

Определение

Возвращает число страниц в форме после ее разбиения на страницы. Этот API устарел. Сведения о разработке ASP.NET мобильных приложений см. в статье Мобильные приложения & сайты с 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

Значение свойства

Число страниц в форме после ее разбиения на страницы.

Атрибуты

Примеры

В следующем примере кода показано, как использовать 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

Комментарии

Элемент Form управления предоставляет PageCount свойство и CurrentPage свойство , которые предоставляют сведения о том, как текущая форма разбивается на страницы. Свойство PageCount также помогает обеспечить возможность навигации по другой странице. Например, при отрисовке на расширенном устройстве форма результатов поиска может включать элементы пользовательского интерфейса для конкретного устройства, которые позволяют пользователю переходить на страницу результатов по количеству, а не по ссылкам.

Примечание

Это значение доступно после Paginated возникновения события. Чтобы получить PageCount свойство , можно обработать Paginated событие формы.

Применяется к

См. также раздел