复选框在Windows应用程序中的用途太广泛了, 下面, 我们看看BCB中的复选框, 代码如下:
//---------------------------------------------------------------------------
#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 = 0;
if(CheckBox1->Checked)
{
result += 1;
}
if(CheckBox2->Checked)
{
result += 2;
}
if(CheckBox3->Checked)
{
result += 4;
}
ShowMessage(result); // 应用程序根据result的结果便知用户的选择
}
//------------------------------------------

本文介绍了在BCB(Borland C++ Builder)中如何使用TCheckBox控件进行复选框操作。复选框在Windows应用程序中扮演重要角色,通过代码示例,展示了在BCB中实现复选框功能的方法。
1075

被折叠的 条评论
为什么被折叠?



