湖南发展集团王修林:可编辑的MSFlexGrid:
来源:百度文库 编辑:中财网 时间:2024/04/29 16:09:51
Private Sub Form_Load()
Dim fs As New FileSystemObject
Dim txtf As TextStream
Dim path As String, Line As String
Dim Cells() As String, Idx As Integer
path = App.path
If Right(path, 1) <> "" Then path = path & ""
Set txtf = fs.OpenTextFile(path & "score.txt", ForReading)
With MSFlexGrid1
.AllowUserResizing = flexResizeColumns ' 可以改变列宽
.Cols = 5 ' 列数 = 5
.Rows = 1 ' 行数暂订 1
.FixedCols = 0 ' 固定列 = 0
' 设置标题
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "语文"
.TextMatrix(0, 3) = "数学"
.TextMatrix(0, 4) = "英语"
.ColAlignment(0) = flexAlignRightCenter
.ColAlignment(2) = flexAlignRightCenter
.ColAlignment(3) = flexAlignRightCenter
.ColAlignment(4) = flexAlignRightCenter
End With
Idx = 1
While Not txtf.AtEndOfStream
Line = txtf.ReadLine
Cells = Split(Line, ",")
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1 ' 增加一行
' 将Cells(0°4) 指定给TextMatrix(Idx, 0°4)
For I = 0 To UBound(Cells)
MSFlexGrid1.TextMatrix(Idx, I) = Cells(I)
Next
Idx = Idx + 1
Wend
txtf.Close
End Sub
Private Sub MSFlexGrid1_Click()
Dim c As Integer, r As Integer
With MSFlexGrid1
c = .Col: r = .Row
Text1.Left = .Left + .ColPos©
Text1.Top = .Top + .RowPos®
If .Appearance = 1 Then
Text1.Left = Text1.Left + 2 * Screen.TwipsPerPixelX
Text1.Top = Text1.Top + 2 * Screen.TwipsPerPixelY
End If
Text1.Width = .ColWidth©
Text1.Height = .RowHeight®
Text1.Text = .Text
End With
Text1.Visible = True
Text1.SetFocus
End Sub
Private Sub MSFlexGrid1_Scroll()
Text1.Visible = False
End Sub
Private Sub Text1_Change()
MSFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then ' 按下 Enter 键
Text1.Visible = False
End If
End Sub
Private Sub Text1_LostFocus()
Text1.Visible = False
End Sub
其中score.txt文件内容为:
850301,陈桶一,90,76,98
850302,黄光权,58,77,75
850303,胡生妙,41,14,33
850304,王为全,95,97,87
850305,李日正,59,66,57
850306,刘德昌,28,11,33
850307,方正一,98,100,100
850308,刘康保,0,0,10
850309,谢掬花,95,74,89
850310,王美兰,41,46,49
850311,徐小当,91,99,84
850312,叶小毛,0,10,0
850313,林东海,92,92,88
850314,林大阳,35,19,29
850315,钟德级,98,90,91
850316,刘力锦,47,50,55
850317,方小房,94,94,100
850318,刘纪成,79,85,77
850319,李普三,84,74,58
850320,刘一心,54,57,64
850321,方日通,83,80,94
850322,刘顺成,71,65,73
850323,谢利利,20,25,10
850324,王涵合,93,100,90
850325,徐佳佳,68,56,39
850326,李红仁,25,24,0
850327,林大玉,87,77,92
850328,林玉成,64,90,59
850329,钟百达,0,0,20
Edited by: LionCSQ
Dim fs As New FileSystemObject
Dim txtf As TextStream
Dim path As String, Line As String
Dim Cells() As String, Idx As Integer
path = App.path
If Right(path, 1) <> "" Then path = path & ""
Set txtf = fs.OpenTextFile(path & "score.txt", ForReading)
With MSFlexGrid1
.AllowUserResizing = flexResizeColumns ' 可以改变列宽
.Cols = 5 ' 列数 = 5
.Rows = 1 ' 行数暂订 1
.FixedCols = 0 ' 固定列 = 0
' 设置标题
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "语文"
.TextMatrix(0, 3) = "数学"
.TextMatrix(0, 4) = "英语"
.ColAlignment(0) = flexAlignRightCenter
.ColAlignment(2) = flexAlignRightCenter
.ColAlignment(3) = flexAlignRightCenter
.ColAlignment(4) = flexAlignRightCenter
End With
Idx = 1
While Not txtf.AtEndOfStream
Line = txtf.ReadLine
Cells = Split(Line, ",")
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1 ' 增加一行
' 将Cells(0°4) 指定给TextMatrix(Idx, 0°4)
For I = 0 To UBound(Cells)
MSFlexGrid1.TextMatrix(Idx, I) = Cells(I)
Next
Idx = Idx + 1
Wend
txtf.Close
End Sub
Private Sub MSFlexGrid1_Click()
Dim c As Integer, r As Integer
With MSFlexGrid1
c = .Col: r = .Row
Text1.Left = .Left + .ColPos©
Text1.Top = .Top + .RowPos®
If .Appearance = 1 Then
Text1.Left = Text1.Left + 2 * Screen.TwipsPerPixelX
Text1.Top = Text1.Top + 2 * Screen.TwipsPerPixelY
End If
Text1.Width = .ColWidth©
Text1.Height = .RowHeight®
Text1.Text = .Text
End With
Text1.Visible = True
Text1.SetFocus
End Sub
Private Sub MSFlexGrid1_Scroll()
Text1.Visible = False
End Sub
Private Sub Text1_Change()
MSFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then ' 按下 Enter 键
Text1.Visible = False
End If
End Sub
Private Sub Text1_LostFocus()
Text1.Visible = False
End Sub
其中score.txt文件内容为:
850301,陈桶一,90,76,98
850302,黄光权,58,77,75
850303,胡生妙,41,14,33
850304,王为全,95,97,87
850305,李日正,59,66,57
850306,刘德昌,28,11,33
850307,方正一,98,100,100
850308,刘康保,0,0,10
850309,谢掬花,95,74,89
850310,王美兰,41,46,49
850311,徐小当,91,99,84
850312,叶小毛,0,10,0
850313,林东海,92,92,88
850314,林大阳,35,19,29
850315,钟德级,98,90,91
850316,刘力锦,47,50,55
850317,方小房,94,94,100
850318,刘纪成,79,85,77
850319,李普三,84,74,58
850320,刘一心,54,57,64
850321,方日通,83,80,94
850322,刘顺成,71,65,73
850323,谢利利,20,25,10
850324,王涵合,93,100,90
850325,徐佳佳,68,56,39
850326,李红仁,25,24,0
850327,林大玉,87,77,92
850328,林玉成,64,90,59
850329,钟百达,0,0,20
Edited by: LionCSQ
关于VB的MSFlexGrid控件
可编辑的GHOST
关于VB中的MSFlexGrid控件的属性
VB中,把一个MSFlexGrid的样式copy给另一个MSFlexGrid
Dreamweaver的删除可编辑区域
求可编辑mpg视频文件的处理软件
急问:vb中MSHFlexGrid与MSFlexGrid的区别
vb编程 MSFlexGrid 控件的几个小问题
3DMAX中,可编辑网络与可编辑多边形的区别
可编辑扫描仪
关于Dreamweaver MX 2004“可编辑区域”的问题
如何将mpag4文件转换为可编辑的视频文件?
数码相机拍的word文档可进行编辑吗?
如何将扫描文件转成可编辑的wps文件
可编辑扫描文字的程序哪有下载?
如何用dreamweaver做一个弹出可编辑的层
用什么软件可编辑能打开程序的链接
欲求论文《可编辑逻辑器件应用前景的探讨》
如何将PHOTOSHOP中的索引变成可编辑的图片!
有没有打印时可编辑的报表控件?
什么软件或者语言可编辑小的应用程序
哪位可以提供一个可编辑的Adobe Reader版本
幻灯片如何转换成可编辑的CAD格式
图片中的字怎么变成可编辑的文档??