TColorGrid,,component,delphi

Omar 10/12/2016 0

This examples demonstrates how to use the TColorGrid component.

Delphi
 procedure TForm4.btnSetForegroundClick(Sender: TObject);
begin
  { If the value entered in the background edit box exists in the color grid, }
  if ColorGrid1.ColorToIndex(HexStringToInt(edForegroundColor.Text)) <> -1 then
    { then change the foreground color. }
    ColorGrid1.ForegroundIndex := ColorGrid1.ColorToIndex
      (HexStringToInt(edForegroundColor.Text));
end;
 
procedure TForm4.btnSetBackgroundClick(Sender: TObject);
begin
  { If the value entered in the background edit box exists in the color grid,}
  if ColorGrid1.ColorToIndex(HexStringToInt(edBackgroundColor.Text)) <> -1 then
    { then change the background color.}
    ColorGrid1.BackgroundIndex := ColorGrid1.ColorToIndex
      (HexStringToInt(edBackgroundColor.Text));
end;
 
procedure TForm4.btnNoForegroundClick(Sender: TObject);
begin
  { Disable the foreground. }
  ColorGrid1.ForegroundEnabled := False;
  { Clear the edit box that contains the foreground color. }
  edForegroundColor.Clear;
end;
 
procedure TForm4.btnNoBackgroundClick(Sender: TObject);
begin
  { Disable the background. }
  ColorGrid1.BackgroundEnabled := False;
  { Clear the edit box that contains the background color. }
  edBackgroundColor.Clear;
end;
 
procedure TForm4.cbClickEnablesFBClick(Sender: TObject);
begin
  { If you click No Background/No Foreground and cbClickEnablesFB is unchecked,
    then clicking the color grid will no longer select the foreground or background. }
  ColorGrid1.ClickEnablesColor := cbClickEnablesFB.Checked;
end;
 
procedure TForm4.ColorGrid1Change(Sender: TObject);
begin
  ColorGrid1.SetFocus;
  { When the color grid changes, set the background and foreground hexadecimal
   color codes from the two edit boxes to the new values. }
  edBackgroundColor.Text := IntToHex(ColorGrid1.BackgroundColor, 6);
  edForegroundColor.Text := IntToHex(ColorGrid1.ForegroundColor, 6);
end; 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments