Delphi – Radio group, IF THEN ELSE and itemindex


Use the file below to show your students how the itemindex works in the radiogroup in Delphi. It also incorporates IF, THEN and ELSE.

screenshot_Sat_Jul_11_16.25.14

screenshot_Sat_Jul_11_16.19.36

procedure TForm1.btnGoClick(Sender: TObject);
begin
  if (rgpWeek.ItemIndex = 0) then
  lblDay.Caption := 'Monday'
  else if (rgpWeek.ItemIndex = 1) then
  lblDay.Caption := 'Tuesday'
  else if (rgpWeek.ItemIndex = 2) then
  lblDay.Caption := 'Wednesday'
  else if (rgpWeek.ItemIndex = 3) then
  lblDay.Caption := 'Thursday'
  else if (rgpWeek.ItemIndex = 4) then
  lblDay.Caption := 'Friday'
  else if (rgpWeek.ItemIndex = 5) then
  lblDay.Caption := 'Saturday'
  else if (rgpWeek.ItemIndex = 6) then
  lblDay.Caption := 'Sunday';
end;

You can also download the UNIT and PROJECT file below (or from the Resources folder in the IT section)


The rest of this content is available to full members. Full membership of the site is available by either donating R100 on the Donation page, or uploading an activity or assessment that you yourself have created to share with others (on the Upload page).

 

Similar Posts: