标题:msflexgrid在指定单元格中响应键盘事件
只看楼主
zqswj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-16
结帖率:100%
已结贴  问题点数:10 回复次数:2 
msflexgrid在指定单元格中响应键盘事件
比如,第1列为"商品编号",在第一行“商品编号”中按下键盘,可响应事件,调出隐藏的textbox.
搜索更多相关主题的帖子: 键盘 商品 
2011-04-17 02:11
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1817
专家分:3681
注 册:2011-3-24
得分:0 
程序代码:
Dim a As Integer, b As Integer

Private Sub Form_Load()
    MSFlexGrid1.Rows = 10
    MSFlexGrid1.Cols = 10
End Sub

Private Sub EditBinName(a As Integer, b As Integer)
    
    With MSFlexGrid1
        Text1.Left = .Left + .ColPos(a) + 2 * Screen.TwipsPerPixelX
        Text1.Top = .Top + .RowPos(b) + 2 * Screen.TwipsPerPixelY
        Text1.Width = .ColWidth(a)
        Text1.Text = .Text
        Text1.SelStart = 0
        Text1.SelLength = Len(BinNameText)
    End With
    Text1.Visible = True
    Text1.SetFocus
    
End Sub

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        a = MSFlexGrid1.MouseCol
        b = MSFlexGrid1.MouseRow
        Call EditBinName(a, b)
    End If
End Sub

不要選我當版主
2011-04-17 15:32
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1817
专家分:3681
注 册:2011-3-24
得分:10 
会错意了~原来你要的更简单~但是这是鼠标的~键盘怎么操作格子~
是按左右键就会显示内容到其他地方的意思嘛?

MSFlexGrid , TextBox
程序代码:
Private Sub EditBinName(a As Integer, b As Integer)
   With MSFlexGrid1
        Text2.Text = .TextMatrix(a, b)
    End With
End Sub

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        a = MSFlexGrid1.MouseCol
        b = MSFlexGrid1.MouseRow
        Call EditBinName(a, b)
    End If
End Sub


也许等同鼠标~按下就原位置+1~其他比照办理~反正一开始步都要先用鼠标点个位置开始的?

[ 本帖最后由 wube 于 2011-4-17 19:55 编辑 ]

不要選我當版主
2011-04-17 19:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-336949-1-1.html




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

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