Back to Devexpress

TdxStatusBarStateIndicatorItem Class

vcl-dxstatusbar-7b886cc2.md

latest4.7 KB
Original Source

TdxStatusBarStateIndicatorItem Class

A state indicator.

Declaration

delphi
TdxStatusBarStateIndicatorItem = class(
    TCollectionItem
)

Remarks

State indicators are simple colored UI elements designed to display enabled/disabled states for individual features in an application.

Main API Members

The list below outlines key members of the TdxStatusBarStateIndicatorItem class. These members allow you to configure state indicators.

State Indicator Settings

IndicatorTypeAllows you to switch between available state indicator colors.VisibleSpecifies if the state indicator is visible.

Collection-Related API Members

CollectionProvides access to the parent state indicator collection.IndexSpecifies the indicator’s index in the parent collection.

Code Example: Create State Indicators

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 TdxStatusBarStateIndicatorItem Class References

The following public API members reference a TdxStatusBarStateIndicatorItem object:

TdxStatusBarStateIndicators.AddCreates a state indicator and adds it to the collection.TdxStatusBarStateIndicators.InsertCreates a state indicator and inserts it at the specified position in the collection.TdxStatusBarStateIndicators.ItemsProvides indexed access to all state indicators stored in the collection.

Inheritance

TObject TPersistent TCollectionItem TdxStatusBarStateIndicatorItem

See Also

TdxStatusBarStateIndicatorItem Members

dxStatusBar Unit