GraphDemo.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "GraphDemo.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "MSChart20Lib_OCX"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- UpDown1->Min=1;
- UpDown1->Max=MSChart1->ColumnCount;
- UpDown2->Min=1;
- UpDown2->Max=MSChart1->RowCount;
- //设置控件参数
- MSChart1->Column=1;
- MSChart1->Row=1;
- Edit3->Text=MSChart1->Data;
- //显示第一行、第一列的数据
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ComboBox1Click(TObject *Sender)
- {
- MSChart1->chartType=ComboBox1->ItemIndex;
- //设置图表类型
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
- {
- MSChart1->Column=UpDown1->Position;
- MSChart1->Row=UpDown2->Position;
- Edit3->Text=MSChart1->Data;
- //显示选中的行和列中的数据
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::UpDown2Click(TObject *Sender, TUDBtnType Button)
- {
- MSChart1->Column=UpDown1->Position;
- MSChart1->Row=UpDown2->Position;
- Edit3->Text=MSChart1->Data;
- //显示选中行和选中列的数据
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if(MSChart1->ColumnCount<10)
- {
- MSChart1->ColumnCount=MSChart1->ColumnCount+1;
- //添加一行
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- if(MSChart1->RowCount<10)
- {
- MSChart1->RowCount=MSChart1->RowCount+1;
- //添加一列
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- if(MSChart1->ColumnCount>1)
- {
- MSChart1->ColumnCount=MSChart1->ColumnCount-1;
- //删除一行
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button4Click(TObject *Sender)
- {
- if(MSChart1->RowCount>1)
- {
- MSChart1->RowCount=MSChart1->RowCount-1;
- //删除一列
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit3Change(TObject *Sender)
- {
- MSChart1->Data=Edit3->Text;
- //修改数据
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::MSChart1DataUpdated(TObject *Sender, short *axisID,
- short *AxisIndex, short *labelSetIndex, short *LabelIndex,
- short *MouseFlags, short *Cancel)
- {
- UpDown1->Min=1;
- UpDown1->Max=MSChart1->ColumnCount;
- UpDown2->Min=1;
- UpDown2->Max=MSChart1->RowCount;
- //更新控件参数
- }
- //---------------------------------------------------------------------------