Form.PageCount Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the number of pages in the form after the form is paginated. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with 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
The number of pages in the form after the form is paginated.
- Attributes
The following code example demonstrates how to use the PageCount property of the Form control. This code example is part of a larger example for the ControlToPaginate property.
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
The Form control exposes the PageCount property and the CurrentPage property, which provide information about how the current form is paginated. The PageCount property also helps provide navigation capability to another page. For example, when rendering on a richer device, a search results form might include device-specific UI elements that allow the user to browse to a page of results by number rather than by link navigation.
Примітка
This value is available after the Paginated event has occurred. To get the PageCount property, you can handle the Paginated event of the form.
Продукт | Версії |
---|---|
.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 |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: