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

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "GraphDemo.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "MSChart20Lib_OCX"
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::FormCreate(TObject *Sender)
  17. {
  18. UpDown1->Min=1;
  19. UpDown1->Max=MSChart1->ColumnCount;
  20. UpDown2->Min=1;
  21. UpDown2->Max=MSChart1->RowCount;
  22. //设置控件参数
  23. MSChart1->Column=1;
  24. MSChart1->Row=1;
  25. Edit3->Text=MSChart1->Data;
  26. //显示第一行、第一列的数据
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::ComboBox1Click(TObject *Sender)
  30. {
  31. MSChart1->chartType=ComboBox1->ItemIndex;
  32. //设置图表类型
  33.         
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
  37. {
  38. MSChart1->Column=UpDown1->Position;
  39. MSChart1->Row=UpDown2->Position;
  40. Edit3->Text=MSChart1->Data;
  41. //显示选中的行和列中的数据
  42.         
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::UpDown2Click(TObject *Sender, TUDBtnType Button)
  46. {
  47. MSChart1->Column=UpDown1->Position;
  48. MSChart1->Row=UpDown2->Position;
  49. Edit3->Text=MSChart1->Data;
  50. //显示选中行和选中列的数据
  51.         
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TForm1::Button1Click(TObject *Sender)
  55. {
  56.         if(MSChart1->ColumnCount<10)
  57.         {
  58.                 MSChart1->ColumnCount=MSChart1->ColumnCount+1;
  59.                 //添加一行
  60.         }
  61.         
  62. }
  63. //---------------------------------------------------------------------------
  64. void __fastcall TForm1::Button3Click(TObject *Sender)
  65. {
  66.         if(MSChart1->RowCount<10)
  67.         {
  68.                 MSChart1->RowCount=MSChart1->RowCount+1;
  69.                 //添加一列
  70.         }
  71.         
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TForm1::Button2Click(TObject *Sender)
  75. {
  76.         if(MSChart1->ColumnCount>1)
  77.         {
  78.                 MSChart1->ColumnCount=MSChart1->ColumnCount-1;
  79.                 //删除一行
  80.         }
  81.         
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TForm1::Button4Click(TObject *Sender)
  85. {
  86.         if(MSChart1->RowCount>1)
  87.         {
  88.                 MSChart1->RowCount=MSChart1->RowCount-1;
  89.                 //删除一列
  90.         }
  91.         
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TForm1::Edit3Change(TObject *Sender)
  95. {
  96.         MSChart1->Data=Edit3->Text;
  97.         //修改数据
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TForm1::MSChart1DataUpdated(TObject *Sender, short *axisID,
  101.       short *AxisIndex, short *labelSetIndex, short *LabelIndex,
  102.       short *MouseFlags, short *Cancel)
  103. {
  104. UpDown1->Min=1;
  105. UpDown1->Max=MSChart1->ColumnCount;
  106. UpDown2->Min=1;
  107. UpDown2->Max=MSChart1->RowCount;
  108. //更新控件参数
  109.         
  110. }
  111. //---------------------------------------------------------------------------