Back to Devexpress

TdxRibbonCaptionAreaSearchToolbar Class

vcl-dxribbon-56954288.md

latest8.5 KB
Original Source

TdxRibbonCaptionAreaSearchToolbar Class

Stores settings of the Caption Area Search Toolbar in a Ribbon UI.

Declaration

delphi
TdxRibbonCaptionAreaSearchToolbar = class(
    TdxRibbonCustomToolbar
)

Remarks

The Caption Area Search Toolbar allows users to access important functionality through the form caption, similar to the search box found in Microsoft Office® 365 applications.

Supported Ribbon Style

The caption area search toolbar is available only for the Office 365 Ribbon style. If the parent TdxRibbon control’s Style property value changes from rsOffice365 to a different value, the embedded bar automatically moves to the tab area search toolbar.

Tip

Like the tab area search toolbar, the caption area search toolbar can contain multiple bar items.

Main API Members

The list below outlines key members of the TdxRibbonCaptionAreaSearchToolbar class. These members allow you to configure a search toolbar displayed within the caption area of a Ribbon form if the parent TdxRibbon control’s Style property is set to rsOffice365.

AlignmentAllows you to position the search toolbar within the parent Ribbon form’s caption area.RibbonProvides access to the parent TdxRibbon control.ToolbarSpecifies the toolbar whose nested bar items are displayed in the parent Ribbon form’s caption area.VisibleAllows you to hide or display the search toolbar.

Code Example: Display an Office Search Box in a Ribbon Form Caption

The following code example creates a TdxOfficeSearchBox editor, associates it with an existing TdxRibbon control, and embeds the created editor into the Ribbon Form caption:

delphi
uses
  dxRibbonForm, // Declares the TdxRibbonForm class
  dxOfficeSearchBox; // Declares the TdxOfficeSearchBox class
// ...
procedure TMyForm.FormCreate(Sender: TObject);
var
  ABar: TdxBar;
  ABarItem: TcxBarEditItem;
  ASearchBoxProperties: TdxOfficeSearchBoxProperties;
  AIconFolder: string;
begin
  DisableAero := True; // Allows the DevExpress Skin Engine to draw non-client form areas
  AIconFolder := 'C:\Program Files (x86)\DevExpress\VCL\ExpressLibrary\Sources\Icon Library\';
  dxRibbon1.Style := rsOffice365; // Selects the Office 365 style with support for form caption toolbars
  ABar := dxBarManager1.Bars.Add; // Creates a toolbar as a container for the Office Search Box
  ABar.Visible := True; // Displays the created toolbar container
  ABarItem := ABar.ItemLinks.AddItem(TcxBarEditItem).Item as TcxBarEditItem;
  ABarItem.PropertiesClass := TdxOfficeSearchBoxProperties;
  ASearchBoxProperties := ABarItem.Properties as TdxOfficeSearchBoxProperties;
  ASearchBoxProperties.BeginUpdate; // Initiates the following batch change
  try
    ASearchBoxProperties.SearchSource := dxRibbon1; // Associates the Office Search Box with the Ribbon UI
    ASearchBoxProperties.Nullstring := 'Tell me what you want to do...';
    ASearchBoxProperties.UseNullString := True; // Displays the defined null string in the empty editor
    ASearchBoxProperties.Glyph.LoadFromFile(AIconFolder + 'SVG Images\Icon Builder\Business_Idea.svg');
    ASearchBoxProperties.Glyph.SourceWidth := 16; // Explicitly specifies the required glyph width
    ASearchBoxProperties.Glyph.SourceHeight := 16; // Explicitly specifies the required glyph height
    ASearchBoxProperties.ShowResultPaths := True; // Displays navigation paths to found UI commands
  finally
    ASearchBoxProperties.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
  dxRibbon1.CaptionAreaSearchToolbar.Toolbar := ABar; // Displays the toolbar container in the caption area
  dxRibbon1.CaptionAreaSearchToolbar.Alignment := TdxRibbonCaptionAreaSearchToolbarAlignment.Left;
end;
cpp
#include "dxRibbonForm.hpp" // Declares the TdxRibbonForm class
#include "dxOfficeSearchBox.hpp" // Declares the TdxOfficeSearchBox class
// ...
void __fastcall TMyForm::FormCreate(TObject *Sender)
{
  TdxBar *ABar;
  TcxBarEditItem *ABarItem;
  TdxOfficeSearchBoxProperties *ASearchBoxProperties;
  UnicodeString AIconFolder;
  DisableAero = true; // Allows the DevExpress Skin Engine to draw non-client form areas
  dxRibbon1->Style = rsOffice365; // Selects the Office 365 style with support for form caption toolbars 
  ABar = dxBarManager1->Bars->Add(); // Creates a toolbar as a container for the office search box
  ABar->Visible = true; // Displays the created toolbar container
  AIconFolder = "C:\\Program Files (x86)\\DevExpress\\VCL\\ExpressLibrary\\Sources\\Icon Library\\";
  ABarItem = dynamic_cast<TcxBarEditItem*>(ABar->ItemLinks->AddItem(__classid(TcxBarEditItem))->Item);
  ABarItem->PropertiesClass = __classid(TdxOfficeSearchBoxProperties);
  ASearchBoxProperties = dynamic_cast<TdxOfficeSearchBoxProperties*>(ABarItem->Properties);
  ASearchBoxProperties->BeginUpdate(); // Initiates the following batch change
  try
  {
    ASearchBoxProperties->SearchSource = dxRibbon1; // Associates the office search box with the Ribbon UI
    ASearchBoxProperties->Nullstring = "Tell me what you want to do...";
    ASearchBoxProperties->UseNullString = true; // Displays the defined null string in the empty editor
    ASearchBoxProperties->Glyph->LoadFromFile(AIconFolder + "SVG Images\\Icon Builder\\Business_Idea.svg");
    ASearchBoxProperties->Glyph->SourceWidth = 16; // Explicitly specifies the required glyph width
    ASearchBoxProperties->Glyph->SourceHeight = 16; // Explicitly specifies the required glyph height
    ASearchBoxProperties->ShowResultPaths = true; // Displays navigation paths to found UI commands
  }
  __finally
  {
    ASearchBoxProperties->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
  }
  dxRibbon1->CaptionAreaSearchToolbar->Toolbar = ABar; // Displays the toolbar container in the caption area
  dxRibbon1->CaptionAreaSearchToolbar->Alignment = TdxRibbonCaptionAreaSearchToolbarAlignment::Left;
};

Other Docked Ribbon Toolbar Container Types

The TdxRibbon control also supports the following docked Ribbon toolbar containers:

TdxRibbonQuickAccessToolbarContains the Ribbon Quick Access Toolbar‘s settings.TdxRibbonTabAreaSearchToolbarContains the Ribbon Tab Area Search Toolbar‘s settings.TdxRibbonTabAreaToolbarContains the Ribbon Tab Area Toolbar‘s settings.

Direct TdxRibbonCaptionAreaSearchToolbar Class Reference

The TdxCustomRibbon.CaptionAreaSearchToolbar property references a TdxRibbonCaptionAreaSearchToolbar object.

Inheritance

TObject TPersistent TInterfacedPersistent TdxRibbonCustomToolbar TdxRibbonCaptionAreaSearchToolbar

See Also

TdxRibbonTabAreaSearchToolbar Class

TdxRibbonCaptionAreaSearchToolbar Members

dxRibbon Unit