Back to Devexpress

TdxStatusBarStateIndicators Class

vcl-dxstatusbar-e32e1f10.md

latest5.3 KB
Original Source

TdxStatusBarStateIndicators Class

A collection of state indicators in a status bar.

Declaration

delphi
TdxStatusBarStateIndicators = class(
    TOwnedCollection
)

Remarks

An indicator panel is designed to display simple colored indicators within a status bar component.

Main API Members

The list below outlines key members of the TdxStatusBarStateIndicators class. These members allow you to manage a state indicator collection.

Collection Management

AddCreates a state indicator and adds it to the collection.ClearClears the collection.DeleteDeletes an individual state indicator in the collection.CountReturns the number of state indicators in the collection.InsertCreates a state indicator and inserts it to a specified position in the collection.ItemsProvides indexed access to state indicators in the collection.

General-Purpose API Members

AssignCopies indicator collections between panels.BeginUpdate | EndUpdateAllow you to avoid excessive redraw operations during batch indicator collection changes.

Code Example: Create and Populate Indicator Panels

The following code example creates an indicator panel in an existing TdxStatusBarPanel component and populates the panel with five different indicators:

delphi
uses
  dxStatusBar; // Declares the TdxStatusBarPanel component and all related types
// ...

var
  AIndicatorPanel: TdxStatusBarPanel;
  AIndicators: TdxStatusBarStateIndicators;
begin
  AIndicatorPanel := dxStatusBar1.Panels.Add;
  AIndicatorPanel.PanelStyleClass := TdxStatusBarStateIndicatorPanelStyle;
  AIndicators := (AIndicatorPanel.PanelStyle as TdxStatusBarStateIndicatorPanelStyle).Indicators;
  AIndicators.BeginUpdate; // Initiates the following batch change
  try
    AIndicators.Add.IndicatorType := sitRed;
    AIndicators.Add.IndicatorType := sitYellow;
    AIndicators.Add.IndicatorType := sitGreen;
    AIndicators.Add.IndicatorType := sitPurple;
    AIndicators.Add.IndicatorType := sitOff;
  finally
    AIndicators.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
end;
cpp
#include "dxStatusBar.hpp" // Declares the TdxStatusBarPanel component and all related types

// Add the following linker directive to the corresponding CPP source file:
#pragma link "dxStatusBar" // Required to use dxStatusBar.hpp declarations

  // ...
  TdxStatusBarPanel *AIndicatorPanel;
  TdxStatusBarStateIndicators *AIndicators;

  AIndicatorPanel = dxStatusBar1->Panels->Add();
  AIndicatorPanel->PanelStyleClass = __classid(TdxStatusBarStateIndicatorPanelStyle);
  AIndicators = dynamic_cast<TdxStatusBarStateIndicatorPanelStyle*>(AIndicatorPanel->PanelStyle)->Indicators;
  AIndicators->BeginUpdate(); // Initiates the following batch change
  try
  {
    AIndicators->Add()->IndicatorType = sitRed;
    AIndicators->Add()->IndicatorType = sitYellow;
    AIndicators->Add()->IndicatorType = sitGreen;
    AIndicators->Add()->IndicatorType = sitPurple;
    AIndicators->Add()->IndicatorType = sitOff;
  }
  __finally
  {
    AIndicators->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
  }

Direct TdxStatusBarStateIndicators Class Reference

The TdxStatusBarStateIndicatorPanelStyle.Indicators property references a TdxStatusBarStateIndicators object.

Inheritance

TObject TPersistent TCollection TOwnedCollection TdxStatusBarStateIndicators

See Also

TdxStatusBarPanels Class

TdxStatusBarStateIndicators Members

dxStatusBar Unit