你好,请问VB MSHFlexGrid1 一行没有数据时,单击右键时不弹出右键菜单?
1个回答
展开全部
Private Sub Form_Load()
MSHFlexGrid1.Cols = 4
Dim i As Integer
For i = 0 To 10
MSHFlexGrid1.AddItem 1 & vbTab & 2 & vbTab & 3 & vbTab & 4
Next
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
'判断鼠标是否在选择行上
' If MSHFlexGrid1.Rows > 2 And Button = vbRightButton Then
' Dim sY As Single, eY As Single
' sY = MSHFlexGrid1.RowPos(MSHFlexGrid1.Row)
' eY = sY + MSHFlexGrid1.RowHeight(MSHFlexGrid1.Row)
' If y > sY And y < eY Then
'弹出菜单
' MsgBox (MSHFlexGrid1.Row)
' End If
' End If
'检查鼠标所在行的数据是否为空
If MSHFlexGrid1.Rows > 2 And Button = vbRightButton Then
Dim r As Integer
For r = MSHFlexGrid1.TopRow To MSHFlexGrid1.Rows
If y < MSHFlexGrid1.RowPos(r) + MSHFlexGrid1.RowHeight(r) Then
Dim c As Integer
For c = 0 To 3
If MSHFlexGrid1.TextMatrix(r, c) <> "" Then
'弹出菜单
MsgBox r
Exit For
End If
Next
Exit For
End If
Next
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询