DBChart如何在点击时现示数据库的记录?(看来有点难喔!) (40分)

  • 主题发起人 主题发起人 懒少爷
  • 开始时间 开始时间

懒少爷

Unregistered / Unconfirmed
GUEST, unregistred user!
在DBChart上有几个series,都是来自一个query,其中一个是点,我想要用户点击这些点时,在
另外一处(如用Label1.caption)显示相应的Query记录,应用哪些属性,方法,在哪个事件里作?
 
Applies to
TChart component
Declaration
property OnClickSeries : TChartClickSeries;
Description
An OnClickSeries event occurs whenever the user clicks onto any Chart Series point. The Sender parameter specifies the Chart component that originated the event. The Series parameter is the corresponding clicked Series component, and the ValueIndex parameter refers to the exact clicked point in the Series. Series have also an OnClick event that can be used individually to catch clicked points. The Button, Shift, X and Y parameters determine the mouse button and mouse cursor coordinates at the time the Series point was clicked.
WARNING:
Use the CancelMouse property to control how the mouse button behaves with dual modes (scroll or zoom after a ClickOnSeries event)
 
这个事件我研究过,就是不会用,看下面是它的例子,如何可以取得点A的X轴Query1filed1.value?
以及Y轴的Query1.filed2.value?
请帮加上代码.
procedure TForm1.DBChart1ClickSeries (Sender: TCustomChart;
Series: TChartSeries;
ValueIndex: Longint;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
ShowMessage(' Clicked Series: '+Series.Name+' at point: '+ inttostr(valueindex));
end;

 
Sorry......
 
看看它的DATASOURCE、VALUES。这个东西我没有用过,让你失望了。
 
procedure TForm1.DBChart1ClickSeries (Sender: TCustomChart;
Series: TChartSeries;
ValueIndex: Longint;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
XFieldValue,YFieldValue :do
uble;
// 最近的数据点对应的字段值
XV,YV ;
// 鼠标位置对应于X,Y轴上的坐标值
begin
Series.GetCursorValues(XV,YV);
XFieldValue := Series.XValues[ValueIndex];
YFieldValue := Series.YValues[ValueIndex];

ShowMessage(' Clicked Series: '+Series.Name+
' at point: '+ inttostr(valueindex) +
#13#10 + FloatToStr(XFieldValue) +
#13#10 + FloatToStr(YFieldValue));
end;
 
谢谢,
其实我想还要访问其字段的...
OK!但还有一个问题,
我的X轴是日期类型,(在Series的Datetime打了勾),这样Xvalue(indexValue)类型是Double,
而它的值是37275.26248...诸如这样的值,如何把它变回标准的日期格式?因为没有一个叫
floatToDatetime的function呀?
 
tdatetime是double型的,搞掂了.
 
多人接受答案了。
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
738
SUNSTONE的Delphi笔记
S
S
回复
0
查看
730
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部