Interaction between multiple sRadioGroups

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #52694
    Support
    Keymaster

      Hello, thank you for the demo.

      I'm not sure where is a reason of the problem, but I see a same behaviour with standard controls.

      Maybe I not quite understand a problem…

      #52706
      JohnG
      Participant
        Quote:

        but I see a same behaviour with standard controls.

        Yes, I see that now. So the problem lies somewhere in the original component.

        Quote:

        Maybe I not quite understand a problem…

        The problem is that the Radiogroup's ItemIndex changes unexpectedly (when there is more than 1 Radiogroup). If I replace the sRadioGroup with sComboBox, then setting/getting config values works as expected. Now, when I set an ItemIndex := 1 it stays as configured.

        I do think the visual presentation using a Radiogroup looks better for this particular case, though. Perhaps you could consider this an opportunity to improve on the original component? 😉

        John

        #52713
        Support
        Keymaster

          I should make an easier test app firstly, because your application has a many code which can have influence.

          I'll try make such application soon.

          #52718
          JohnG
          Participant

            Hello,

            The first demo was more complex than needed. But there was a reason for that: to demonstrate and confirm that my config set/get technique was working correctly — it was, except for the Radiogroups.

            Attached is a stripped-down demo, using only 2 Radiogroups. There is also a Combobox demo attached. Both projects use the exact same code, except for the Radiogroup vs the Combobox on the Config form.

            It's hard to believe that there are such problems with a Radiogroup, after all these years of Delphi development. I would be happy to be shown the error of my ways. 🙂

            John

            [attachment=6953:Radiogroup Test.zip]

            [attachment=6954:Combobox Test.zip]

            #52721
            Support
            Keymaster

              I found a reason of the prob, look this code:

              Code:
              procedure TfrmConfig.GetConfigVals;
              begin
              rgSw1.ItemIndex := dmMyDM.Sw[1]; // Here rgSw1Click called and array is changed. Before – (0,0), after (0, 1)
              rgSw2.ItemIndex := dmMyDM.Sw[2];
              end;

              procedure TfrmConfig.rgSw1Click(Sender: TObject);
              begin
              with dmMyDM do
              begin
              Sw[1] := rgSw1.ItemIndex;
              Sw[2] := rgSw2.ItemIndex;
              end;
              end;

              So, dmMyDM.Sw array is changed when you changes the ItemIndex (because rgSw1Click called).

              #52730
              JohnG
              Participant

                Thankyou! I was stuck in my own view and couldn't see this.

                Not an AC problem, so especially thanks for taking the time to look.

                John

              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.