TButtonColor
Posted: Tue Nov 17, 2015 5:17 pm
Is there some documentation or a good example of the use of the TButtonColor component? I have not been able to find much information.
Thanks,
Thanks,
Here you have another example with two:TButtonColor wrote:Description
This Button control is internally used at Chart Editor dialogs.
It's like a normal TButton control, but includes a property to "link" this button to a Color property.
The Color is used to display a graphical filled rectangle at the right side of the button.
Clicking the button will automatically show the Color editor dialog to change the color.
Example:
Code: Select all
ButtonPen1.LinkProperty( Series1, 'SeriesColor' );
Code: Select all
uses Series;
var Series1: TLineSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
Series1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
Series1.FillSampleValues();
Series1.Pointer.Visible:=true;
Series1.Pointer.Color:=Series1.Color;
ButtonColor1.LinkProperty(Series1, 'SeriesColor');
ButtonColor2.LinkProperty(Series1.Pointer.Brush, 'Color');
end;
Exactly. You just have to link a TColor property to it.fjrohlf wrote:So one does not have to enter any code for the button's onclick event?
The code I posted above does it for me here. Doesn't for you?fjrohlf wrote:That works very well - but how does one set the initial color of the "symbol"? Initially it is black and it does change once one clicks on it and selects a color but I would like it to start with a specified color (i.e., the existing color of a series).
After cleaning any 3rd party reference I made the simplified example to work with this code:fjrohlf wrote:Unfortunately, It uses some components from TMS but you should be able to see my buttoncolor code.
Code: Select all
procedure TForm2.FormCreate(Sender: TObject);
var
i: integer;
Series1: TpointSeries;
seriesarray: array [1 .. 3] of TpointSeries;
buttonsarray: array [1 .. 3] of TButtonColor;
ButtonColori: TButtonColor;
begin
Chart1.View3D := false;
Chart1.Legend.Visible := false;
for i := 1 to 3 do begin
Series1 := Chart1.AddSeries(TpointSeries) as TpointSeries;
seriesarray[i] := Series1;
Series1.FillSampleValues();
ButtonColori := TButtonColor.Create(self);
buttonsarray[i] := ButtonColori;
buttonsarray[i].Parent := Self;
buttonsarray[i].Left := 15;
buttonsarray[i].Top := buttonsarray[i].Height * i + 15;
buttonsarray[i].Caption := IntToStr(i) + ' ';
buttonsarray[i].SymbolWidth := 30;
buttonsarray[i].LinkProperty(Series1,'SeriesColor');
end;
end;
Code: Select all
Series1.Color := clRed;
Code: Select all
procedure TForm2.FormCreate(Sender: TObject);
var
i: integer;
Series1: TpointSeries;
seriesarray: array [1 .. 3] of TpointSeries;
buttonsarray: array [1 .. 3] of TButtonColor;
ButtonColori: TButtonColor;
begin
Chart1.View3D := false;
Chart1.Legend.Visible := false;
for i := 1 to 3 do begin
Series1 := Chart1.AddSeries(TpointSeries) as TpointSeries;
seriesarray[i] := Series1;
Series1.FillSampleValues();
ButtonColori := TButtonColor.Create(self);
buttonsarray[i] := ButtonColori;
buttonsarray[i].Parent := Self;
buttonsarray[i].Left := 15;
buttonsarray[i].Top := buttonsarray[i].Height*i + 5;
buttonsarray[i].Caption := IntToStr(i) + ' ';
buttonsarray[i].SymbolWidth := 30;
ButtonColori.LinkProperty(Series1,'SeriesColor');
end;
Series1.Color := clRed;
end;