[SOLVED] CheckBox, not getting expected result lazarus / 16-Databases ---------------------------------------------------------------------- Elmug · 2012-07-20 02:54 Hi everyone. I put CheckBox1 on Form1. And OnFormActivate, these line is the code:   CheckBox1.Enabled := SQLQuery1.Active;  {Valid, since both are booleans} The expected result is that CheckBox1 should appear CHECKED, since I have set the SQLQuery1 Active = True by design, but CheckBox1 shows UNCHECKED. How come this is so? PS: I want to start monitoring status of components relating to database use, in order to figure certain things out. Thanks! ---------------------------------------------------------------------- paweld · 2012-07-20 04:16 move Code: [Select]CheckBox1.Enabled := SQLQuery1.Active; from Form1.OnActivate to SQLQuery1.AfterOpen ---------------------------------------------------------------------- Elmug · 2012-07-20 04:37 Quote from: paweld on July 20, 2012, 06:16:07 ammove Code: [Select]CheckBox1.Enabled := SQLQuery1.Active; from Form1.OnActivate to SQLQuery1.AfterOpen Hi and thanks for helping, paweld. I tried your suggestion and it did not work. In fact, the problem seems to me, is in the equating of the two entities, for I have even tried activating the same one line of code with a pushbutton, and the checkbox does not show "checked". In fact, also, with the same button I change the caption of a label (to detect the state) and that does work, of course, meaning the code to set the label value and the one line of code using the booleans is in the same block of code to the onclick of the button. Any explanations, or corrections? P.S. I am coming to believe that even though they both are booleans, the booleans are not compatible. Thanks! ---------------------------------------------------------------------- taazz · 2012-07-20 05:07 Quote from: Elmug on July 20, 2012, 04:54:21 amHi everyone. I put CheckBox1 on Form1. And OnFormActivate, these line is the code:   CheckBox1.Enabled := SQLQuery1.Active;  {Valid, since both are booleans} The expected result is that CheckBox1 should appear CHECKED, since I have set the SQLQuery1 Active = True by design, but CheckBox1 shows UNCHECKED. Well Enabled is not used to control the check box's state. Try setting the Checked instead. Code: [Select]  CheckBox1.Checked := SQLQuery1.Active; ---------------------------------------------------------------------- Elmug · 2012-07-20 05:30 Quote from: taazz on July 20, 2012, 07:07:19 amWell Enabled is not used to control the check box's state. Try setting the Checked instead. Code: [Select]  CheckBox1.Checked := SQLQuery1.Active;  Hi Taazz and thanks! You are most correct. It does it. And, poweld, I DID relocate the action to SQLQuery1.AfterOpen, which is a much better place to have it. And I also trigger that one line by code, from other procedures, to refresh the checkbox.