BCB动态定义对象,如何使用?
scytb.hpp程序如下:
#pragma hdrstop
#include "scytb.h"
//---------------------------------------
#pragma package(smart_init)
#pragma link "base16"
#pragma resource "*.dfm"
Tscytb_Form *scytb_Form;
TLineSeries *series_sc;//定义一个全局的图表折线series
//---------------------------------------
__fastcall Tscytb_Form::Tscytb_Form(TComponent* Owner)
: Tbase16_Form(Owner)
{
}
//---------------------------------------
void __fastcall Tscytb_Form::FormCreate(TObject *Sender)
{
// 初始化
、、、、、
int i=0;
UQRY->First();
while (!UQRY->Eof)
{
//有多少机器,就有多少条折线
series_sc=new TLineSeries(this);
series_sc->Name="series_sc"+IntToStr(i);//折线名称有了
series_sc->ParentChart=DBChart1;
、、、、
DBChart1->AddSeries(series_sc);
i=i+1;
UQRY->Next();
}
}
//---------------------------------------
void __fastcall Tscytb_Form::BitBtn1Click(TObject *Sender)
{
//这里想用series_sc3,不知道该如何使用
}
//---------------------------------------
[解决办法]
在DBChart中去找相应的series就行
[解决办法]
if (DBChart1->SeriesCount() > 2)
{
DBChart1->Series[2]->Title = "123";
}