MsChart为什么每次偷掉我一行数据!

Happiness 2002-11-22 11:45:14
很简单的用法,放一个MsChart,一个按钮
在按钮点击的时候先查出一个记录集rs,然后
Set MsChart1.DataSource = rs
但是我的第一行数据总是显示不出来,被微软偷走了?
我知道可以自己加一行来避免,但是如果这样,那等于DataSource属性是没有用的了,难道微软这么弱智??

欢迎讨论!
...全文
24 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Happiness 2002-11-22
  • 打赏
  • 举报
回复
原来如此!
谢谢!
of123 2002-11-22
  • 打赏
  • 举报
回复
第一行数据有时会作为X轴每个点的文本,
数据类型是字符还是数字,忘了,
试试就知道了,
不知道你是否是这种情况。
^_^

不要瞎猜。这就是MSChart的缺陷,它不会自动移位到第一条记录。见资料:
*****************************************************************
Avoid the MSChart glitch when displaying ADO Recordset data


When you assign an ADO Recordset to an MSChart's DataSource property, the resulting chart may not contain the first row of data. Normally, when you create a Recordset object, ADO automatically moves the cursor to the first record (assuming the recordset contains records). As a result, there's no need to issue the MoveFirst command. Unfortunately, unless you issue this command, MSChart skips over the first record for some reason. As a result, when you use the MSChart control with an ADO Recordset, always move the cursor to the first record before you assign it to the chart, as seen here:

Dim rst As ADODB.Recordset
Dim sql As String
Set rst = New ADODB.Recordset
sql = "SELECT * FROM tblChartData"
With rst
.ActiveConnection = "Provider=Microsoft.Jet" & _
".OLEDB.4.0;Data Source=D:\DBPath\db1.mdb"
.Open sql, , adOpenStatic
.MoveFirst
End With
Set MSChart1.DataSource = rst
rst.Close
Set rst = Nothing
*****************************************************************

dwei 2002-11-22
  • 打赏
  • 举报
回复
第一行数据有时会作为X轴每个点的文本,
数据类型是字符还是数字,忘了,
试试就知道了,
不知道你是否是这种情况。
^_^
of123 2002-11-22
  • 打赏
  • 举报
回复
是一个Bug.

......
rs.movefirst
Set MsChart1.DataSource = rs
......

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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