Unit2.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:2k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit2.h"
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TForm2 *Form2;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm2::TForm2(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm2::FormCreate(TObject *Sender)
  17. {
  18. int i;
  19. int j;
  20. //定义变量
  21. Form2->StringGrid1->ColCount=Form1->VtChart1->ColumnCount+1;
  22. Form2->StringGrid1->RowCount=Form1->VtChart1->RowCount+1;
  23. //设置表格的大小
  24. for (i=0;i<=Form1->VtChart1->ColumnCount;i++)
  25.     {
  26.     Form2->StringGrid1->Cells[i][0]=IntToStr(i);
  27.     }
  28. for (j=0;j<=Form1->VtChart1->RowCount;j++)
  29.     {
  30.     Form2->StringGrid1->Cells[0][j]=IntToStr(j);
  31.     }
  32.     //设置表格的标题
  33. for (i=1;i<=Form1->VtChart1->ColumnCount;i++)
  34.     {
  35.     for (j=1;j<=Form1->VtChart1->RowCount;j++)
  36.     {
  37.     Form1->VtChart1->Column=i;
  38.     Form1->VtChart1->Row=j;
  39.     Form2->StringGrid1->Cells[i][j]=Form1->VtChart1->Data;
  40.     //初始化表格中的数据
  41.     }
  42.     }
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm2::Button1Click(TObject *Sender)
  46. {
  47. int i;
  48. int j;
  49. //变量定义
  50. for (i=1;i<=Form1->VtChart1->ColumnCount;i++)
  51.     {
  52.     for (j=1;j<=Form1->VtChart1->RowCount;j++)
  53.     {
  54.     Form1->VtChart1->Column=i;
  55.     Form1->VtChart1->Row=j;
  56.     Form1->VtChart1->Data=Form2->StringGrid1->Cells[i][j];
  57.     //以表格中的数据填充图表
  58.     }
  59.     }
  60. Form1->Show();
  61. Form2->Hide();
  62. //显示主窗体
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TForm2::Button2Click(TObject *Sender)
  66. {
  67. Form1->Show();
  68. Form2->Hide();
  69. //显示主窗体
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
  73. {
  74. Form1->Show();
  75. //显示主窗体
  76. }
  77. //---------------------------------------------------------------------------
  78.