MSHFlexGrid是不是不能编辑单元格?我仿照了使MSFlexGrid能编辑单元格的方法想……

myriverman 2004-04-29 04:44:01
MSHFlexGrid 是不是不能编辑单元格?我仿照了使 MSFlexGrid 能编辑单元格的方法想
使MSHFlexGrid能编辑单元格,写了如下代码

Private Sub MSHFlexGrid1_DblClick()
Dim c As Integer
Dim r As Integer
With MSHFlexGrid1
c = .Col: r = .Row
Text7.Left = .Left + .ColPos(c)
Text7.Top = .Top + .RowPos(r)
Text7.Width = .ColWidth(c)
Text7.Height = .RowHeight(r)
Text7 = .Text
Text7.Visible = True
Text7.SetFocus
End With
End Sub

为什么这句无法通过Text7.Width = .ColWidth(c),请指点一下
...全文
70 1 点赞 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
leolan 2004-04-29
'不用TestBox也可以做到

Option Explicit

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
'Provides manual data entry capability to flexgrid

With MSFlexGrid1

Select Case KeyAscii
Case vbKeyReturn
If .Col + 1 <= .Cols - 1 Then
.Col = .Cols - 1
ElseIf .Row + 1 <= .Rows - 1 Then
.Row = .Row + 1
.Col = 0
Else
.Row = 1
.Col = 0
End If
Case vbKeyBack
If Trim(.Text) <> "" Then
.Text = Mid(.Text, 1, Len(.Text) - 1)
End If
Case Is < 32
Case Else
If .Col = 0 Or .Row = 0 Then
Exit Sub
Else
.Text = .Text & Chr(KeyAscii)
End If
End Select
End With
End Sub
  • 打赏
  • 举报
回复
相关推荐
发帖
VB基础类
加入

7546

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2004-04-29 04:44
社区公告
暂无公告