Link to home
Start Free TrialLog in
Avatar of Elohim Panggalo
Elohim Panggalo

asked on

i have two radiobutton and a click button. how to show warning message when none of the radiobutton checked?

User have to choose one from two radiobutton. When they havent choose ,how to show a warning box (mesaage box), is it possible?
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that depends ...
when you set a radiobutton as checked at design time, then you can't select nothing
unchecking a radiobutton doesn't work, checking another radiobutton, unchecks all others in the same container/panel
so, if you set a default radiobutton as checked, then you will never get that situation

but with a construction like this you could check for zero

function TForm1.Checked: Integer;
begin
  Result := 0;
  if RadioButton1.Checked then
    Result := 1
  else if RadioButton2.Checked then
    Result := 2;
end;

procedure TForm1.Button1Click(Sender: TObject);
var S: string;
begin
  S := 'No selection was made';
  case checked of
    1: s := 'You selected radiobutton 1';
    2: s := 'You selected radiobutton 2';
  end;
  MessageDlg(s, mtWarning, [mbOk], 0);
end;

Open in new window

reading a book about Delphi should get you going way faster

like SAM's Teach yourself Delphi in 24 hours
Avatar of Elohim Panggalo
Elohim Panggalo

ASKER

sorry, im newbie, this is my first time  programming. thx for keep answering
really ? newbie ?

well, the first time usually does hurt :)