| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2303 人关注过本帖
标题:msflexgrid 不能显示。
只看楼主 加入收藏
vbtom
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-9-5
收藏
 问题点数:0 回复次数:10 
msflexgrid 不能显示。

请看下段程序有什么问题,msflexgrid没有内容显示。也没有报错。谢谢!
Option Explicit
Public Sub ShowTitle()
With msgComputer
.Cols = 11
.TextMatrix(0, 1) = "Building"
.TextMatrix(0, 2) = "Department"
.TextMatrix(0, 3) = "Current User"
.TextMatrix(0, 4) = "Machine Name"
.TextMatrix(0, 5) = "Model"
.TextMatrix(0, 6) = "Serial Number"
.TextMatrix(0, 7) = "Monitor SN"
.TextMatrix(0, 8) = "Configuration"
.TextMatrix(0, 9) = "Lan MAC"
.TextMatrix(0, 10) = "Wireless MAC"
.ColWidth(0) = 500
.ColWidth(1) = 500
.ColWidth(2) = 500
.ColWidth(3) = 1000
.ColWidth(4) = 500
.ColWidth(5) = 1000
.ColWidth(6) = 1500
.ColWidth(7) = 1500
.ColWidth(8) = 2000
.ColWidth(9) = 2000
.ColWidth(10) = 2000
.FixedRows = 1
End With
End Sub
Public Sub ShowData()
Dim i As Integer
Dim strsqlcomputer As String
Dim objrstcomputer As New Recordset
strsqlcomputer = "Select * from computer"
objrstcomputer.Open strsqlcomputer, cnn, adOpenDynamic, adLockPessimistic
msgComputer.Rows = objrstcomputer.RecordCount + 1
objrstcomputer.MoveFirst
For i = 1 To objrstcomputer.RecordCount
msgComputer.TextMatrix(i, 1) = objrstcomputer.Fields(0)
msgComputer.TextMatrix(i, 2) = objrstcomputer.Fields(1)
msgComputer.TextMatrix(i, 3) = objrstcomputer.Fields(2)
msgComputer.TextMatrix(i, 4) = objrstcomputer.Fields(3)
msgComputer.TextMatrix(i, 5) = objrstcomputer.Fields(4)
msgComputer.TextMatrix(i, 6) = objrstcomputer.Fields(5)
msgComputer.TextMatrix(i, 7) = objrstcomputer.Fields(6)
msgComputer.TextMatrix(i, 8) = objrstcomputer.Fields(7)
msgComputer.TextMatrix(i, 9) = objrstcomputer.Fields(8)
msgComputer.TextMatrix(i, 10) = objrstcomputer.Fields(9)
If objrstcomputer.EOF Then
Exit For
End If
Next i
End Sub

Private Sub Form_Load()
ShowTitle
ShowData
End Sub

[此贴子已经被作者于2007-9-12 17:11:31编辑过]

搜索更多相关主题的帖子: quot msflexgrid TextMatrix Department Monitor 
2007-09-12 17:05
qlong0728
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:272
专家分:0
注 册:2007-6-15
收藏
得分:0 
改成
For i = 1 To objrstcomputer.RecordCount
msgComputer.TextMatrix(i, 1) = objrstcomputer.Fields(0)
msgComputer.TextMatrix(i, 2) = objrstcomputer.Fields(1)
msgComputer.TextMatrix(i, 3) = objrstcomputer.Fields(2)
msgComputer.TextMatrix(i, 4) = objrstcomputer.Fields(3)
msgComputer.TextMatrix(i, 5) = objrstcomputer.Fields(4)
msgComputer.TextMatrix(i, 6) = objrstcomputer.Fields(5)
msgComputer.TextMatrix(i, 7) = objrstcomputer.Fields(6)
msgComputer.TextMatrix(i, 8) = objrstcomputer.Fields(7)
msgComputer.TextMatrix(i, 9) = objrstcomputer.Fields(8)
msgComputer.TextMatrix(i, 10) = objrstcomputer.Fields(9)
objrstcomputer.movenext '加上这句
If objrstcomputer.EOF Then
Exit For
End If
Next i

程序人员写程序,又拿程序换酒钱。 奔驰宝马贵者趣,公交自行程序员。 不见满街漂亮妹,哪个归得程序员。
2007-09-12 17:18
qlong0728
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:272
专家分:0
注 册:2007-6-15
收藏
得分:0 
其实
If objrstcomputer.EOF Then
Exit For
End If

这段可以不用,多余的

程序人员写程序,又拿程序换酒钱。 奔驰宝马贵者趣,公交自行程序员。 不见满街漂亮妹,哪个归得程序员。
2007-09-12 17:20
vbtom
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-9-5
收藏
得分:0 
谢谢!加了这一句,还是没有显示!
2007-09-12 17:23
qlong0728
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:272
专家分:0
注 册:2007-6-15
收藏
得分:0 

再前面再加上
msgComputer.Rows = objrstcomputer.RecordCount + 1
msgComputer.Cols = 10

[此贴子已经被作者于2007-9-12 17:31:07编辑过]


程序人员写程序,又拿程序换酒钱。 奔驰宝马贵者趣,公交自行程序员。 不见满街漂亮妹,哪个归得程序员。
2007-09-12 17:30
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
objrstcomputer.MoveFirst
do while not objrs.eof
if msgComputer.rows=2 and msgComputer.TextMatrix(1,1)='' then msgComputer.rows =msgComputer.rows +1
for i=1 to msgComputer.cols
msgComputer.TextMatrix(msgComputer.rows -1 , i) = objrstcomputer.Fields(i-1)
Next i
objrs.movenext
loop
msgComputer的屬性不太記得了。。上面的列和行會有些錯誤。。。不過上面的方法可以

2007-09-12 17:34
vbtom
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-9-5
收藏
得分:0 
让两位大侠见笑了。问题还没解决。用西风老大的方法,总是提示" Run-time error 94, Invalid use of Null"
参考了网上的一些方法,程序整理如下,可仍然有Invalid use of Null错误(指向循环体内)。为什么呀?很烦。不想用datagrid.

Public Sub ShowData()
Dim iRow As String
Dim strsqlcomputer As String
Dim objrstcomputer As New ADODB.Recordset
strsqlcomputer = "select * from computer"
If objrstcomputer.State = 1 Then objrstcomputer.Close
objrstcomputer.Open strsqlcomputer, cnn, adOpenKeyset, adLockPessimistic
msgComputer.Cols = 11
With msgComputer
.Redraw = False
.Rows = 2
iRow = 0
objrstcomputer.MoveFirst
Do While Not objrstcomputer.EOF
iRow = iRow + 1
If iRow >= .Rows Then .Rows = .Rows + 1
.TextMatrix(iRow, 1) = Trim(objrstcomputer.Fields(0))
.TextMatrix(iRow, 2) = Trim(objrstcomputer.Fields(1))
.TextMatrix(iRow, 3) = Trim(objrstcomputer.Fields(2))
.TextMatrix(iRow, 4) = Trim(objrstcomputer.Fields(3))
.TextMatrix(iRow, 5) = Trim(objrstcomputer.Fields(4))
.TextMatrix(iRow, 6) = Trim(objrstcomputer.Fields(5))
.TextMatrix(iRow, 7) = Trim(objrstcomputer.Fields(6))
.TextMatrix(iRow, 8) = Trim(objrstcomputer.Fields(7))
.TextMatrix(iRow, 9) = Trim(objrstcomputer.Fields(8))
.TextMatrix(iRow, 10) = Trim(objrstcomputer.Fields(9))
objrstcomputer.MoveNext
Loop
End With

End Sub
2007-09-14 15:27
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
根据你的情况已修正:
MSF.Cols = 10
MSF.FormatString = "^Building |^Department|^Current User|^Machine Name|^Model|^Serial Number |^Monitor SN |^Configuration |^Lan MAC |^Wireless MAC "
’上面的列Building ,如果要长上点的话,在后面加空格就可以了。。。
Set objRs = Nothing
objRs.Open " select * from table", PobjCn, adOpenKeyset
If objRs.RecordCount > 0 Then
Do While Not objRs.EOF
If MSF.TextMatrix(1, 0) <> "" Then MSF.Rows = MSF.Rows + 1
For j = 0 To MSF.Cols - 1
MSF.TextMatrix(MSF.Rows - 1, j) = IIf(IsNull(objRs.Fields(j)), "", objRs.Fields(j))
Next
objRs.MoveNext
Loop
End If
MSF.ColSel = MSF.Cols - 1

[此贴子已经被作者于2007-9-14 15:56:24编辑过]


2007-09-14 15:39
西风独自凉
Rank: 8Rank: 8
等 级:贵宾
威 望:43
帖 子:3380
专家分:28
注 册:2007-8-2
收藏
得分:0 
ShowTitle()你这个过程不用了。
二句搞定:
MSF.Cols =11
MSF.FormatString = "^Building |^b |^c |^d |^e |^f "

2007-09-14 15:42
vbtom
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-9-5
收藏
得分:0 
谢谢,西风老大,刚才做了一下测试,OK。thank you again!
2007-09-14 16:07
快速回复:msflexgrid 不能显示。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012818 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved