Recent

Author Topic: how do I check to see if an item in the RadioGroup is checked?  (Read 16397 times)

userx-bw

  • Full Member
  • ***
  • Posts: 178
how do I check to see if an item in the RadioGroup is checked?
« on: January 20, 2014, 12:38:24 am »
how do I check to see if an item in the  RadioGroup is checked?

in the examples I have read they all say like this
Code: [Select]
if radio1.Checked then
with the group not a single radio button but the TRadioGroup
these do not work.
Code: [Select]
RadioGroup.checked
RadioGroup.Items.Checked
RedioGroup.ItemsIndex.Checked
RadioGroup.Items[RadioGroup.ItemsIndex].checked


reguardles if it is caps or not, Checked, or checked I get an error
Code: [Select]
mhsetroot.pas(433,36) Error: identifier idents no member "Checked"


so How do I check to see if a selection is checked or selected within a TRadioGroup?


My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how do I check to see if an item in the RadioGroup is checked?
« Reply #1 on: January 20, 2014, 12:42:55 am »
RadioGroup1.ItemIndex <> -1;
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: how do I check to see if an item in the RadioGroup is checked?
« Reply #2 on: January 20, 2014, 12:52:29 am »
Please disregard this post. I just realized that I confused TCheckGroup with your question regarding TRadioGroup:-[  Thanks to Taazz

Quote
how do I check to see if an item in the  RadioGroup is checked?

Code: [Select]
if CheckGroup1.Checked[TheIndexOfTheItemYouWant] then
  //do something

If you want to know how many items are checked:
Code: [Select]
  i, NumOfCheckedItems: integer;
begin
  NumOfCheckedItems := 0;
  for i := 0 to CheckGroup1.Items.Count - 1 do
  begin
    if CheckGroup1.Checked[i] then
      NumOfCheckedItems += 1;
  end;
« Last Edit: January 20, 2014, 01:18:09 am by engkin »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how do I check to see if an item in the RadioGroup is checked?
« Reply #3 on: January 20, 2014, 01:11:27 am »
Radiogroup only allows one item select at a time.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: how do I check to see if an item in the RadioGroup is checked?
« Reply #4 on: January 20, 2014, 01:34:40 am »
Radiogroup only allows one item select at a time.

I know .. I just need to reset the value to -1 for that radiogroup and all other radioGroups that are not being used, as in my testing to check which radio button is selected then in selecting a different radiogroup the result for the last radiogroup stayed to the same value of whatever was checked last. therefore I need to reset that value of all the radiogroup's not being used to -1 so that I can check to be use that none of them are selected then move on with the code .. for a lack of a better way of putting it ... thanks !
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

 

TinyPortal © 2005-2018