📄 cd2_4u.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "cd2_4u.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
String array[10][6]; //定义一个二维数组array为字符串类型 行数为10,列数为6
//在这里定义,是为了让窗体中所有事件都可以使用此数组
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
sg->Cells[0][0]=" 时段\\日期"; //StringGrid的输出设置需特别注意的是
sg->Cells[0][1]=" 第一节"; //Cells[列][行]与一般数组[行][列]是不同的
sg->Cells[0][2]=" 第二节";
sg->Cells[0][3]=" 第三节"; //用快捷键Ctrl+c及Ctrl+V快速复制程序代码
sg->Cells[0][4]=" 第四节";
sg->Cells[0][5]=" 第五节";
sg->Cells[0][6]=" 第六节";
sg->Cells[0][7]=" 第七节";
sg->Cells[0][8]=" 第八节";
sg->Cells[0][9]=" 第九节";
sg->Cells[1][0]=" 星期一";
sg->Cells[2][0]=" 星期二";
sg->Cells[3][0]=" 星期三";
sg->Cells[4][0]=" 星期四";
sg->Cells[5][0]=" 星期五";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::endClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::addClick(TObject *Sender)
{
int day,tim,i,j; //day代表星期几tim代表第几节课
day=cbd->ItemIndex; //将ComboBox控件cad的事件索引值设置给tim
tim=cbt->ItemIndex; //ComboBox的事件索引值也是从零开始
array[tim][day]=inp->Text; //将Edit控件获取的字符串设置给字符串类型数组array
for(i=0;i<9;i++)
for(j=0;j<5;j++)
sg->Cells[j+1][i+1]=array[i][j]; //通过StringGrid来显示array的输出内容
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -