13,871
社区成员




void CMyGrid::InitGrid()
{
Width = 448;
Height = 245;
int nColumnIndex = 0;
int nRowIndex = 0;
//添加列
for(nColumnIndex = 0; nColumnIndex < 4; ++nColumnIndex)
{
TColumnItem *pNewColumn = ColumnCollection->Add();
pNewColumn->SizeStyle = ssAbsolute;
pNewColumn->Value = nColumnIndex?136:40;
}
//添加行
for(nRowIndex = 0; nRowIndex < 7; ++nRowIndex)
{
TRowItem *pNewRow = RowCollection->Add();
pNewRow->SizeStyle = ssAbsolute;
pNewRow->Value = 35;
}
//初始化第一列
for(nRowIndex = 0; nRowIndex < 7; ++nRowIndex)
{
TLabel* plblText = new TLabel(this);
plblText->Parent = this;
plblText->Align = alClient;
plblText->Alignment = taCenter;
plblText->Layout = tlCenter;
switch(nRowIndex)
{
case 0: plblText->Caption="一"; break;
case 1: plblText->Caption="二"; break;
case 2: plblText->Caption="三"; break;
case 3: plblText->Caption="四"; break;
case 4: plblText->Caption="五"; break;
case 5: plblText->Caption="六"; break;
case 6: plblText->Caption="七"; break;
}
TControlItem* pNewItem = ControlCollection->Add();
pNewItem->Column = 0;
pNewItem->Row = nRowIndex;
pNewItem->Control = plblText;
}
}