Unit2.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:2k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #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();
- //显示主窗体
- }
- //---------------------------------------------------------------------------