Recent

Author Topic: [SOLVED]Read the caption of selected checkbox into TCheckGroup.  (Read 2478 times)

sabouras

  • New Member
  • *
  • Posts: 18
Dear All,
I have a problem with Tcheckgroup. I have 8 different checkoxes inside and i want to read the caption of the selected checkbox, and if it is possible to change the font color.
So could you please guide me how to do that?
Thanks in advance for your time.
Best regards to all.
« Last Edit: June 07, 2017, 04:14:44 am by sabouras »

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Read the caption of selected checkbox into TCheckGroup.
« Reply #1 on: June 06, 2017, 11:05:47 pm »
Code: Pascal  [Select][+][-]
  1. uses Themes;
  2.  
  3. procedure TForm1.FormCreate(Sender: TObject);
  4. begin
  5.   Screen.OnActiveControlChange := @ActiveControlChanged;
  6. end;
  7.  
  8. procedure TForm1.ActiveControlChanged(Sender: TObject);
  9. var
  10.   C: TControl;
  11.   i: Integer;
  12. begin
  13.   i := CheckGroup1.GetControlIndex(ActiveControl);
  14.   if i >= 0 then
  15.   begin
  16.     C := CheckGroup1.Controls[i];
  17.     if C is TCheckBox then
  18.     begin
  19.       Caption := C.Caption;
  20.       if not ThemeServices.ThemesEnabled then
  21.         C.Font.Color := clRed;
  22.     end;
  23.   end;
  24. end;
Works for not-owned checkboxes too.
« Last Edit: June 06, 2017, 11:16:37 pm by ASerge »

sabouras

  • New Member
  • *
  • Posts: 18
Re: [SOLVED]Read the caption of selected checkbox into TCheckGroup.
« Reply #2 on: June 07, 2017, 04:15:05 am »
Thank you sir.

 

TinyPortal © 2005-2018