本文主要是介绍BCB中的TRadioButton单选框,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
单选框在Windows应用程序中到处可见, 比如, 对于一个人来说, 性别只能是男女其一, 此时, 我们可以考虑用单选框(其实, 此时仅仅用一个TCheckBox复选框也可以搞定)。 界面图, 我就不画了, 直接给出代码:
//---------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{
}
//---------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{int result = -1;if(RadioButton1->Checked){result = 1;}if(RadioButton2->Checked){result = 2;}ShowMessage(result);
}
//---------------------------------------------------------------------------
这篇关于BCB中的TRadioButton单选框的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!