Back to Devexpress

TdxBadge.Background Property

vcl-dxuiadorners-dot-tdxbadge-b621ae59.md

latest3.7 KB
Original Source

TdxBadge.Background Property

Provides access to the UI badge’s background settings.

Declaration

delphi
property Background: TdxBadgeBackground read; write;

Property Value

TypeDescription
TdxBadgeBackground

Stores badge background settings.

|

Remarks

Use the Background property to customize the appearance of the badge’s background.

Available Options

Background.Color and Background.Glyph properties allow you to fill the badge background with a solid color or a texture.

Refer to the TdxBadgeBackground class description for detailed information on all available options.

Code Example: Create and Position a UI Element Badge

The following code example creates a badge and moves it up by 5 pixels and right by 50 pixels:

delphi
var
  ABadge: TdxBadge;
  AElementControl: TdxAdornerTargetElementControl;
begin
  dxUIAdornerManager1.BeginUpdate; // Initiates the following batch change
  try
    ABadge := dxUIAdornerManager1.Badges.Add; // Creates a badge
    ABadge.Text := 'Prints the Report'; // Specifies the badge's caption
    ABadge.Offset.X := 50; // Moves the badge right by 50 pixels from the base position
    ABadge.Offset.Y := -5; // Moves the badge up by 5 pixels from the base position
    // Customize the appearance of the created badge
    ABadge.Background.Color := clLime;
    ABadge.Font.Style := [fsBold];
    ABadge.Font.Color := clBlue;
    // Associate the created badge with a TcxButton
    ABadge.TargetElementClass := TdxAdornerTargetElementControl;
    AElementControl := ABadge.TargetElement as TdxAdornerTargetElementControl;
    AElementControl.Control := cxButton1; // Specifies the target button
    dxUIAdornerManager1.Badges.Active := True; // Displays the created badge
  finally
    dxUIAdornerManager1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
  end;
end;
cpp
TdxBadge *ABadge;
  TdxAdornerTargetElementControl *AElementControl;
  // ...
  dxUIAdornerManager1->BeginUpdate(); // Initiates the following batch change
  try
  {
    ABadge = dxUIAdornerManager1->Badges->Add(); // Creates a badge
    ABadge->Text = "Prints the Report"; // Specifies the badge's caption
    ABadge->Offset->X = 50; // Moves the badge right by 50 pixels from the base position
    ABadge->Offset->Y = -5; // Moves the badge up by 5 pixels from the base position
    // Customize the appearance of the created badge
    ABadge->Background->Color = clLime;
    ABadge->Font->Style = TFontStyles() << fsBold;
    ABadge->Font->Color = clBlue;
    // Associate the created badge with a TcxButton
    ABadge->TargetElementClass = __classid(TdxAdornerTargetElementControl);
    AElementControl = dynamic_cast<TdxAdornerTargetElementControl*>(ABadge->TargetElement);
    AElementControl->Control = cxButton1; // Specifies the target button
    dxUIAdornerManager1->Badges->Active = true; // Displays the created badge
  }
  __finally
  {
    dxUIAdornerManager1->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
  }

See Also

TdxBadge.Font Property

TdxBadge.Text Property

TdxBadge Class

TdxBadge Members

dxUIAdorners Unit