请问:RadioGroup如何表示被选中
我不知道如何表示RadioGroup是否被选中,所以用了一种笨办法,
先设Items为“男”“女”
程序如下:
procedure TForm1.FormCreate(Sender: TObject);
begin
RadioGroup1.ItemIndex:=-1;
if (RadioGroup1.ItemIndex=-1) then
button1.Caption:='无';
if RadioGroup1.ItemIndex=0 then
button1.Caption:='男';
if RadioGroup1.ItemIndex=1 then
button1.caption:='女'
else
button1.Caption:='不男不女';
showmessage(inttostr(RadioGroup1.ItemIndex));
end;
结果showMessage弹出-1,而button.caption为“不男不女”。真怪!
请问这是什么原因啊?正规的判断RadioGroup是否被选中的方法又是如何?
谢谢。