Similar to the question which has been posted How to set required Edit fields with a red border? answered by Mr. Bummi
I would like to know, is it possible for using the same implementation for DBCombobox or not?
You could use the following (it is verified on Delphi 10 Seattle).
TDBCombobox = Class(VCL.DBCtrls.TDBCombobox)
private
FBordercolor: TColor;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure SetBorderColor(AColor: TColor);
published
property BorderColor: TColor read FBorderColor write SetBorderColor default clBlack;
end;
....
Implementation
procedure TDBCombobox.WMPaint(var Message: TWMPaint);
begin
inherited;
Self.Canvas.Pen.Color := FBorderColor;
Self.Canvas.Pen.Width := 1;
Self.Canvas.Polyline([Point(0, 0), Point(Width-1, 0), Point(Width - 1, Height - 1),
Point(0, Height - 1),Point(0, 0)]);
end;
procedure TDBCombobox.SetBorderColor(AColor: TColor);
begin
FBorderColor := AColor;
invalidate;
end;
It is the same idea like the post you linked, You use a hack to add features to standard components.
If it is worth it, then you should create a descendant like @kobik said.
If a standard component needs a new feature, then it is not a standard any more.