|Subject:||VCL TRadioButton issue ...|
|Posted by:||newsgroups.borland.com (zlatibor.urosev…@yahoo.it)|
|Date:||Wed, 23 Jul 2008|
Although I am using Delphi since Delphi1 I didn't realize this strange
issue with RadioButtons until now, although I found some referencing
about on google, coming from 2003.
Issue is with TRadioButtons (but applies also on TRadioGroup) and how
you control them run-time from the code.
Here goes example...
I have a main form (form1) from which I open (showmodal) a secondary
form (form2) - within the same program/exe (although it applies on
packages/dlls containing forms too).
On form2 there are two radiobuttons, radiobutton1 having checked := true.
So, I simply:
1) run the program (form1 opens)
2) click the button on form1 which opens form2 (form2.showmodal)
3) there are two radiobuttons, with radiobutton1.checked = true
4) I click on RadioButton2, which becomes checked (unchecking
radiobutton1, at least visually)
5) I close the form2 (clicking on X icon), so the form2 closes/hides
(does not get freed)
6) now on form1 I click another button which sets
form2.radiobutton1.checked to true (which should uncheck radiobutton2 on
form2) and I reopen/showmodal the form2
-> BUT instead of having the radiobutton1.checked = true I still have
the radiobutton2.checked ?!
Now, what I foundis that you cannot set the radiobutton.checked
programatically runtime (it will show correctly but will NOT behave
properly) until you do not ALSO set the radiobutton or any other control
on the form to have focus (or by setting focus, or by using
form.activecontrol := control).
Now question bothering me is:
1) Why the radiobutton.checked = true does NOT work from the code UNLESS
you set the radiobutton or any other CONTROL on the form to have the
focus, or you simple at the other control like button (I am forced to do
something like form2.activecontrol := form2.radiobutton1;
form2.radiobutton1.checked := true in order to have form2 opening with
default radiobutton1 checked regardless of what was clicked/checked the
last time you closed the form2)
2) Is this Delphi/VCL or more generally speaking a Windows/Controls issue
3) Noone, except the few in the past (looking at google groups), didn't
realize/spoke about that issue?
-I am using CodeGear RAD Studio 2007 with all the patches applied, but I
see it was mentioned in the past with Delphi3 as well.
-the issue appears regardless of how you set the tabstop for radiobuttons
-when you click the radio button (or you 'select' it with keyboard it
gets tabstop automatically set to TRUE although it might be set to FALSE ?!
Thanks and Kind Regards,