Skip to main content

TdxBadge.Offset Property

Specifies horizontal and vertical offsets (in pixels) from the UI badge’s base position.

Declaration

property Offset: TdxPoint read; write;

Property Value

Type Description
TdxPoint

Offset.X and Offset.Y properties specify pixel offsets from the base position of the UI badge.

Use TargetElement and Alignment properties to define the base position of the badge.

Remarks

Use Offset.X and Offset.Y properties to move the badge horizontally and vertically from one of the nine base positions at the target UI element.

VCL Editors Library: A Large Badge at the Default Base Position

Position offsets are useful if you need to adjust the position of a large badge that overlaps the target UI element as demonstrated in the code example below.

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:

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;

VCL Editors Library: A Custom Badge for a Button

See Also