property ExPrint.PageRange as String
Specifies the pages being printed.

 TypeDescription 
   String A String expression that specifies the pages being printed. It supports page numbers and/or page ranges separated by commas. For instance: "1,5-7,9-".  If empty, all pages are printed.   
By default, the PageRange property is empty, in other words the print command will send all pages to the printer.  The pages being printed shows in white, while the pages being not printed shows as disabled as in the following screen shots. You can print only a selection from a page by selecting the area using the RIGHT click, and moving the cursor. You can specify a page to be not printed by clicking the page and keeping the CTRL key down, or if it is already not-printed, toggle it's state. If you require only a single page to be printed, you can click the page and press CTRL + SHIFT key. Use the ToolBarFormat property to add new controls to the preview's toolbar. The Click event notifies your application once the user clicks a button in the preview's toolbar. Use the Refresh event to update the buttons' captions when pages are refreshed. The ItemCaption property specifies the button's caption in the preview's toolbar. 

The following VB sample adds a button PageRange to the preview's toolbar, with the identifier 200

Print1.ToolBarFormat = Print1.ToolBarFormat + ",|,200"

At this point, the control's Preview displays a 200 button in the right side of the toolbar as shown bellow:

Now update the newly button's caption with "PageRange" caption, and eventually the current page range value using the Refresh event as follows:

Private Sub Print1_Refresh()
    With Print1
        .ItemCaption(200) = "PageRange"
        If Len(.PageRange) > 0 Then
            .ItemCaption(200) = .ItemCaption(200) + " " + .PageRange
        End If
    End With
End Sub

Next, we need to handle the Click event, so once the button is clicked we can select a new selection for pages being printed, using the PageRange property:

Private Sub Print1_Click(ID As Long, SelectedID As Long)
    If (ID = 200) Then
        Print1.PageRange = InputBox("Specifies the page range", "PageRange", Print1.PageRange)
        Print1.Refresh
    End If
End Sub

Using the Refresh event, the PageRange button is updated as soon as you click a page while the CTRL or CTRL+SHIFT combination is pressed.

The following screen shot shows the pages to be printed in white (1,2), while the others being excluded as disabled:

The following screen shot shows the user selection to be printed ( white rectangle ) ( RIGHT click the cursor and moves the cursor to select the area ):

In C# the sample will be like:

private void exprint1_RefreshEvent(object sender)
{
    exontrol.EXPRINTLib.ItemCaptionEnum idPageRange = (exontrol.EXPRINTLib.ItemCaptionEnum)200;
    exprint1.set_ItemCaption(idPageRange, "PageRange");
    if (exprint1.PageRange.Length > 0)
        exprint1.set_ItemCaption(idPageRange, exprint1.get_ItemCaption(idPageRange) + " " + exprint1.PageRange);

}

private void exprint1_Click(object sender, int ID, int SelectedID)
{
    if (ID == 200)
    {
        exprint1.PageRange = Microsoft.VisualBasic.Interaction.InputBox("Specifies the page range", "PageRange", exprint1.PageRange, 0, 0);
        exprint1.Refresh();
    }
}

In VB/NET the sample will be like:

Private Sub Exprint1_RefreshEvent(ByVal sender As System.Object) Handles Exprint1.RefreshEvent
    With Exprint1
        .set_ItemCaption(200, "PageRange")
        If Len(.PageRange) > 0 Then
            .set_ItemCaption(200, .get_ItemCaption(200) + " " + .PageRange)
        End If
    End With

End Sub

Private Sub Exprint1_Click(ByVal sender As System.Object, ByVal ID As System.Int32, ByVal SelectedID As System.Int32) Handles Exprint1.Click
    If (ID = 200) Then
        With Exprint1
            .PageRange = InputBox("Specifies the page range", "PageRange", .PageRange)
            .Refresh()
        End With
    End If
End Sub
 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.