⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.cpp

📁 C++ Builder 6 编程实例教程-北京希望电子出版社出版
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#include "Unit1.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm2::FormCreate(TObject *Sender)
{
int i;
int j;
//定义变量
Form2->StringGrid1->ColCount=Form1->VtChart1->ColumnCount+1;
Form2->StringGrid1->RowCount=Form1->VtChart1->RowCount+1;
//设置表格的大小
for (i=0;i<=Form1->VtChart1->ColumnCount;i++)
    {
    Form2->StringGrid1->Cells[i][0]=IntToStr(i);
    }
for (j=0;j<=Form1->VtChart1->RowCount;j++)
    {
    Form2->StringGrid1->Cells[0][j]=IntToStr(j);
    }
    //设置表格的标题
for (i=1;i<=Form1->VtChart1->ColumnCount;i++)
    {
    for (j=1;j<=Form1->VtChart1->RowCount;j++)
    {
    Form1->VtChart1->Column=i;
    Form1->VtChart1->Row=j;
    Form2->StringGrid1->Cells[i][j]=Form1->VtChart1->Data;
    //初始化表格中的数据
    }
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)
{
int i;
int j;
//变量定义
for (i=1;i<=Form1->VtChart1->ColumnCount;i++)
    {
    for (j=1;j<=Form1->VtChart1->RowCount;j++)
    {
    Form1->VtChart1->Column=i;
    Form1->VtChart1->Row=j;
    Form1->VtChart1->Data=Form2->StringGrid1->Cells[i][j];
    //以表格中的数据填充图表
    }
    }
Form1->Show();
Form2->Hide();
//显示主窗体
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button2Click(TObject *Sender)
{
Form1->Show();
Form2->Hide();
//显示主窗体
}
//---------------------------------------------------------------------------

void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
Form1->Show();
//显示主窗体
}
//---------------------------------------------------------------------------
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -