-3

How can I set the item index of an item in AdvOfficeRadioGroup1 to -1 when I uncheck the checkbox? Unchecking disables the items but the selection is still visible.

Edit :

enter image description here

user763539
  • 3,509
  • 6
  • 44
  • 103

1 Answers1

0

Attach this code:

PROCEDURE TMainForm.AdvOfficeRadioGroup1CheckBoxClick(Sender : TObject);
  BEGIN
    IF AdvOfficeRadioGroup1.CheckBox.Checked THEN BEGIN
      IF AdvOfficeRadioGroup1.Tag>=0 THEN AdvOfficeRadioGroup1.ItemIndex:=AdvOfficeRadioGroup1.Tag;
      AdvOfficeRadioGroup1.Tag:=-1
    END ELSE BEGIN
      AdvOfficeRadioGroup1.Tag:=AdvOfficeRadioGroup1.ItemIndex;
      AdvOfficeRadioGroup1.ItemIndex:=-1
    END
  END;

to the OnCheckBoxClick event. It will use the AdvOfficeRadioGroup's Tag property to store the previously selected ItemIndex so that it can be restored when you check the checkbox again.

HeartWare
  • 7,464
  • 2
  • 26
  • 30
  • I want the selection removed (emptied). Not kept. – user763539 May 25 '14 at 13:38
  • Then delete the line "IF AdvOfficeRadioGroup1.Tag>=0 THEN AdvOfficeRadioGroup1.ItemIndex:=AdvOfficeRadioGroup1.Tag;" from the code. – HeartWare May 25 '14 at 17:18
  • It works fine here. Could you elaborate on what "does not work" means? What happens when you uncheck the checkbox, and what did you expect to happen? – HeartWare May 26 '14 at 04:10