Back to Devexpress

PrintBarManager.GetBarItemByCommand(PrintingSystemCommand) Method

windowsforms-devexpress-dot-xtraprinting-dot-preview-dot-printbarmanager-dot-getbaritembycommand-x28-devexpress-dot-xtraprinting-dot-printingsystemcommand-x29.md

latest3.7 KB
Original Source

PrintBarManager.GetBarItemByCommand(PrintingSystemCommand) Method

Provides access to a bar item corresponding to the specified command.

Namespace : DevExpress.XtraPrinting.Preview

Assembly : DevExpress.XtraPrinting.v25.2.dll

NuGet Package : DevExpress.Win.Printing

Declaration

csharp
public BarItem GetBarItemByCommand(
    PrintingSystemCommand command
)
vb
Public Function GetBarItemByCommand(
    command As PrintingSystemCommand
) As BarItem

Parameters

NameTypeDescription
commandPrintingSystemCommand

A PrintingSystemCommand enumeration value, specifying the command corresponding to the bar item in question.

|

Returns

TypeDescription
BarItem

A BarItem object, specifying the bar item corresponding to the specified command.

|

Remarks

Each printing system command corresponds to a bar item representing this command in Print Preview GUI.

This method searches the collection for the first bar item executing the specified command and returns this item. When a matching bar item is not found, this method returns an empty BarItem object.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetBarItemByCommand(PrintingSystemCommand) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-winforms-export-doc-odt/CS/WindowsFormsApplication1/Form1.cs#L36

csharp
PrintPreviewFormEx form = (PrintPreviewFormEx)sender;
PrintPreviewBarItem item = (PrintPreviewBarItem)form.PrintBarManager.GetBarItemByCommand(PrintingSystemCommand.ExportFile);
PopupMenu control = (PopupMenu)((DevExpress.XtraBars.BarButtonItem)(item)).DropDownControl;

reporting-winforms-export-doc-odt/VB/WindowsFormsApplication1/Form1.vb#L36

vb
Dim form As PrintPreviewFormEx = DirectCast(sender, PrintPreviewFormEx)
Dim item As PrintPreviewBarItem = CType(form.PrintBarManager.GetBarItemByCommand(PrintingSystemCommand.ExportFile), PrintPreviewBarItem)
Dim control As PopupMenu = CType((CType(item, DevExpress.XtraBars.BarButtonItem)).DropDownControl, PopupMenu)

See Also

PrintBarManager Class

PrintBarManager Members

DevExpress.XtraPrinting.Preview Namespace