vcl-dxuiadorners-dot-tdxcustomadorner-0230564f.md
Specifies the adorner’s target UI element.
property TargetElement: TdxAdornerCustomTargetElement read; write;
| Type | Description |
|---|---|
| TdxAdornerCustomTargetElement |
The target UI element. You need to cast the TargetElement property value to one of the following terminal [TdxAdornerCustomTargetElement] class descendants to access all public API members:
TdxAdornerTargetElementControlAllows you to anchor the adorner to a control on the parent form. This object provides access to the target control through the Control property.TdxAdornerTargetElementPathAllows you to anchor the adorner to UI elements that belong to other controls and components. This object provides access to the target UI element through the Path property. |
Use TargetElement and TargetElementClass properties to associate the adorner with a UI element.
You can use badges to mark or highlight individual UI elements in your application.
The following code example creates UI badges for all groups in a Navigation Bar control and configures badge appearance and position settings:
var
I: Integer;
ABadge: TdxBadge;
AElementPath: TdxAdornerTargetElementPath;
begin
dxUIAdornerManager1.BeginUpdate; // Initiates the following batch change
try
for I := 0 to dxNavBar1.Groups.Count - 1 do // Iterates through all navigation bar groups
begin
ABadge := dxUIAdornerManager1.Badges.Add; // Creates a badge for the corresponding group
ABadge.Text := IntToStr(I); // Uses the group index as the badge caption
// Associate the created badge with the corresponding navigation bar group
ABadge.TargetElementClass := TdxAdornerTargetElementPath;
AElementPath := ABadge.TargetElement as TdxAdornerTargetElementPath;
AElementPath.Path := dxNavBar1.Name + '.' + dxNavBar1.Groups[I].Name;
end;
dxUIAdornerManager1.Badges.Active := True; // Displays created badges
finally
dxUIAdornerManager1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
TdxBadge *ABadge;
TdxAdornerTargetElementPath *AElementPath;
// ...
dxUIAdornerManager1->BeginUpdate(); // Initiates the following batch change
try
{
for(int i = 0; i < dxNavBar1->Groups->Count; i++) // Iterates through all navigation bar groups
{
ABadge = dxUIAdornerManager1->Badges->Add(); // Creates a badge for the corresponding group
ABadge->Text = IntToStr(i); // Uses the group index as the badge caption
// Associate the created badge with the corresponding navigation bar group
ABadge->TargetElementClass = __classid(TdxAdornerTargetElementPath);
AElementPath = dynamic_cast<TdxAdornerTargetElementPath*>(ABadge->TargetElement);
AElementPath.Path = dxNavBar1->Name + "." + dxNavBar1->Groups[i]->Name;
}
dxUIAdornerManager1->Badges->Active = true; // Displays created badges
}
__finally
{
dxUIAdornerManager1->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
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;
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