DBChart的TLineSeries问题

jhldelphi 2009-08-12 04:37:14
界面都是调用下面这个过程的,其它界面调用没问题,
而有一个界面出内存错误,但去掉TLineSeries类型的话就没问题;

代码如下:
//图表类型
procedure Change_Chart_Type(PageCntrl: TPageControl; tmpChart: TChartSeries);
begin
if PageCntrl.ActivePageIndex = 0 then
begin
tmpChart.Marks.Style:= smsValue;
ChangeSeriesType(tmpChart, TBarSeries);
end
else if PageCntrl.ActivePageIndex = 1 then
begin
tmpChart.Marks.Style:= smsLabel;
ChangeSeriesType(tmpChart, TPieSeries);
end
else if PageCntrl.ActivePageIndex = 2 then
begin
tmpChart.Marks.Style:= smsValue;
ChangeSeriesType(tmpChart, TLineSeries); //有内存错误
//ChangeSeriesType(tmpChart, TBarSeries); //无内存错误,但上面已经有了TBarSeries类型
end;

tmpChart.Active:= true;
tmpChart.RefreshSeries;
end;
...全文
254 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
火龙岛主 2009-08-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jhldelphi 的回复:]
引用 1 楼 bdmh 的回复:
TLineSeries和TBarSeries类型不能互转,因为来自不同的父类
TLineSeries, TAreaSeries and the TPointSeries.这三个可以

那要怎么做呢,我要实现类型转换。。。。。。。
[/Quote]

删除后,重新建立。
jhldelphi 2009-08-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
TLineSeries和TBarSeries类型不能互转,因为来自不同的父类
TLineSeries, TAreaSeries and the TPointSeries.这三个可以
[/Quote]
那要怎么做呢,我要实现类型转换。。。。。。。
jhldelphi 2009-08-13
  • 打赏
  • 举报
回复
删除后,重新建立,其他同样没问题,
TLineSeries还是有错误,程序直接死掉。。。。
代码如下:
  else if PageControl1.ActivePageIndex = 2 then
begin
DBChart1.Legend.Visible:= true;

DBChart1.Series[1].Free;
DBChart1.Series[0].Free;

DBChart1.AddSeries( TLineSeries.Create(Self) );
DBChart1.AddSeries( TLineSeries.Create(Self) );

tmpChart:= DBChart1.Series[0];
tmpChart2:= DBChart1.Series[1];

tmpChart.Marks.Style:= smsValue;
tmpChart2.Marks.Style:= smsValue;

tmpChart.Active:= true;
tmpChart2.Active:= false;
//设置dataSource
Chart_GetShow();
end;
zhaixing0101 2009-08-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
TLineSeries和TBarSeries类型不能互转,因为来自不同的父类
TLineSeries, TAreaSeries and the TPointSeries.这三个可以
[/Quote]

应该是其他部分代码的问题吧? 我刚试了下Bar 和Line可以转换
bdmh 2009-08-12
  • 打赏
  • 举报
回复
TLineSeries和TBarSeries类型不能互转,因为来自不同的父类
TLineSeries, TAreaSeries and the TPointSeries.这三个可以

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧