A newer version of this page is available. Switch to the current version.

PrintingSystemBase.SetCommandVisibility(PrintingSystemCommand, CommandVisibility) Method

Changes the visibility of the specified printing system command.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v18.2.Core.dll

Declaration

public void SetCommandVisibility(
    PrintingSystemCommand command,
    CommandVisibility visibility
)
Public Sub SetCommandVisibility(
    command As PrintingSystemCommand,
    visibility As CommandVisibility
)

Parameters

Name Type Description
command PrintingSystemCommand

A PrintingSystemCommand enumeration value which specifies the command whose visibility needs to be changed.

visibility CommandVisibility

A CommandVisibility enumeration value which specifies the new visibility state for the commands.

Remarks

NOTE

The SetCommandVisibility method takes effect only in Windows Forms applications, where it must be called after the DocumentViewer.DocumentSource property has been assigned a value.

Every report command is represented by either a toolbar button and a menu item, or a context menu item, or a verb in the End-User Designer window. The values of the CommandVisibility enumeration represent the visibility states of the command. So, the SetCommandVisibility method allows to change the visibility of a report command. To change the visibility of several report commands at one time, use the overloaded SetCommandVisibility method.

To get the current visibility state of a report command, use the PrintingSystemBase.GetCommandVisibility method.

Examples

This example illustrates how to change the visibility of the toolbar buttons and menu items of a print preview by using the PrintingSystemBase.SetCommandVisibility method that defines the availability of commands in print preview.

The following code hides the Watermark button from the toolbar (together with the corresponding menu item), makes the DocumentMap button and menu item visible, and then makes the ExportToCsv and ExportToTxt commands visible (in both the window's menu, and in the toolbar).

All available commands are listed in the PrintingSystemCommand enumeration.

using DevExpress.XtraPrinting;
// ...

// Get the printing system of the DocumentViewer control.
PrintingSystemBase ps = documentViewer1.PrintingSystem;

// Hide the Watermark toolbar button, and also the Watermark menu item.
if (ps.GetCommandVisibility(PrintingSystemCommand.Watermark) != CommandVisibility.None){
   ps.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None);
}

// Show the Document Map toolbar button and menu item.
ps.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.All);

// Make the "Export to Csv" and "Export to Txt" commands visible.
ps.SetCommandVisibility(new PrintingSystemCommand[] 
   {PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt}, CommandVisibility.All);
See Also