Recent

Author Topic: Check if at least 1 radiobutton is checked in radiogroup  (Read 3295 times)

Handoko

  • Hero Member
  • *****
  • Posts: 4292
  • My goal: build my own game engine using Lazarus
Re: Check if at least 1 radiobutton is checked in radiogroup
« Reply #15 on: May 14, 2021, 11:22:41 am »
Show us the whole source code, that is what I always ask. If OP provides the whole compile-able source code, the issue should be able to solve in minutes.

dseligo

  • Sr. Member
  • ****
  • Posts: 277
Re: Check if at least 1 radiobutton is checked in radiogroup
« Reply #16 on: May 14, 2021, 12:26:52 pm »
Show us the whole source code, that is what I always ask. If OP provides the whole compile-able source code, the issue should be able to solve in minutes.

I posted my code 28 minutes after he asked and he said that it works for him.

dseligo

  • Sr. Member
  • ****
  • Posts: 277
Re: Check if at least 1 radiobutton is checked in radiogroup
« Reply #17 on: May 14, 2021, 12:41:03 pm »
Yes, he said radiogroup but from his code it was clear that he means 'group of radiobuttons'. He tried to access individual controls but he didn't use FindComponent.
I attached small example.
No, not clear at all. My example uses a TRadioGroup, accesses individual controls and does not use FindComponent. So, when somebody is accessing individual radiobuttons of a TRadioGroup does not necessarily mean that he is talking of a "TGroupbox" rather than a "TRadioGroup".

I read his code as attempt to check if there is selected at least one radio button in multiple radio button groups. He tried to solve it by counting checked radio buttons, which he wanted to reference by name. I showed him how to do it and he said that it works for him.
Of course, there are other ways to solve this. In your example it isn't shown how to check if any radio button is selected out of multiple TRadioGroups. And what if he has radio buttons outside of TGroupbox, just on the form?
No hard feelings.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2725
Re: Check if at least 1 radiobutton is checked in radiogroup
« Reply #18 on: May 14, 2021, 12:44:10 pm »
Of course, there are other ways to solve this. In your example it isn't shown how to check if any radio button is selected out of multiple TRadioGroups. And what if he has radio buttons outside of TGroupbox, just on the form?
No hard feelings.

And that is why both Handoko and I have said that OP could usefully show us what he's trying to do, since abusing the functionality that the developers put into the standard controls never ends well.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Handoko

  • Hero Member
  • *****
  • Posts: 4292
  • My goal: build my own game engine using Lazarus
Re: Check if at least 1 radiobutton is checked in radiogroup
« Reply #19 on: May 14, 2021, 12:48:11 pm »
Show us the whole source code, that is what I always ask. If OP provides the whole compile-able source code, the issue should be able to solve in minutes.

I posted my code 28 minutes after he asked and he said that it works for him.

If OP provided the whole source code on his first post, I believe most or maybe all of us can solve it in less than 10 minutes. Compile-time errors are very easy to solve if the whole source code is provided. Not only solving the problem, sometimes there will be suggestions for improving the code quality.

Without the compile-able source code, we just guess. But if I had it, I simple open it using Lazarus, inspect and can fully understand the problem. Lazarus is an awesome IDE tool for debugging.

Usually posters only show some lines of the code where they believe are the cause of the issue. But often, the real problem is on somewhere else.
« Last Edit: May 14, 2021, 01:11:17 pm by Handoko »

 

TinyPortal © 2005-2018