of123和赵4老师 你们好,
你们谁能帮我改一下我做的,我把源代码发给你们,也可以联系我,非常感谢,QQ:2912941929
我是用来输入内容 的,之后引用内容进行计算
新建工程: 添加一个MSHFlexGrid1控件,改名为Grid1;再添加一个TextBox控件,默认名称
代码如下:
Private Sub Form_Activate()
'设置Text1的初始位置
Grid1.Col = 0
Grid1.Row = 0
Grid1.SetFocus
Text1.Left = Grid1.Left + Grid1.CellLeft
Text1.Top = Grid1.Top + Grid1.CellTop
Text1.SetFocus
End Sub
Private Sub Grid1_GotFocus()
Dim I, J As Integer
If Grid1.Row > 1 Then
For I = Grid1.Row To Grid1.rows - 1
For J = 0 To Grid1.cols - 1
Grid1.Row = I
Grid1.Col = J
Grid1.SetFocus
Text1.Left = Grid1.Left + Grid1.CellLeft
Text1.Top = Grid1.Top + Grid1.CellTop
Grid1.Row = 0
Grid1.Col = 0
Grid1.SetFocus
Text1.Left = Grid1.Left + Grid1.CellLeft
Text1.Top = Grid1.Top + Grid1.CellTop
Next J
Next I
Else
For I = 0 To 1
For J = 0 To Grid1.cols - 1
Grid1.Row = I
Grid1.Col = J
Grid1.SetFocus
Text1.Left = Grid1.Left + Grid1.CellLeft
Text1.Top = Grid1.Top + Grid1.CellTop
Next J
Next I
End If
End Sub
Private Sub Form_Load()
Dim I, I2, I3, J, J2, J3, K, K2, K3 As Integer
For I = 0 To Grid1.cols - 1 '设置Grid 控件的宽度
Grid1.ColWidth(I) = 1410
Next I
For I = 0 To Grid1.rows - 1 '设置Grid 控件的高度
Grid1.RowHeight(I) = 400
Next I
Text1.Visible = True
Text1.Width = Grid1.CellWidth - 20
Text1.Height = Grid1.CellHeight - 20
End Sub
'对表格内容读写功能的实现
'当前活动单元更改到一个不同单元时发生,实现text1文本的漂浮跟踪
Private Sub Grid1_EnterCell()
With Text1 '设置Text1的属性【文本漂浮】
.Text = ""
.Visible = False
.Top = Grid1.Top + Grid1.CellTop
.Left = Grid1.Left + Grid1.CellLeft
.Width = Grid1.CellWidth - 20
.Height = Grid1.CellHeight - 20
.Text = Grid1.Text
.Visible = True
End With
End Sub
'对表格内容读写功能的实现
'当前活动单元变更到一个不同的单元之前立即发生,实现Text1文本中的值添加到单元格中
Private Sub Grid1_leavecell()
Grid1.Text = Text1.Text
Text1.Text = ""
Text1.Visible = False
End Sub
'注意:不要删除或修改下列被注释的行!
'MappingInfo=Grid1,grid1,-1,Cols
Public Property Get cols() As Long
cols = Grid1.cols '设置列数【控件设置】
End Property
Public Property Let cols(ByVal New_Cols As Long)
Grid1.cols = New_Cols
PropertyChanged "Cols"
End Property
'Rows代码参考如下:
'MappingInfo = Grid1,Grid1,-1,Rows
Public Property Get rows() As Long
rows = Grid1.rows
End Property
Public Property Let rows(ByVal New_Rows As Long)
Grid1.rows() = New_Rows
prertychanged "rows"
End Property