具有mshflexgrid控件的窗体不允许选择鼠标单击已完成的行。有时,它允许选择上一行,而不是所单击的行
我已经尝试添加一个到mshflexgrid的属性.RowSel以允许行选择,它不能用于第二行选择。
Private Sub MSHFlexGrid1_Click()
last_row_selected = MSHFlexGrid1.RowSel
If last_row_selected <> 1 Then last_row_selected = last_row_selected + 1
With MSHFlexGrid1
If (boolShift And vbShiftMask) = vbShiftMask Then
SelectionOneAfterTheOther
ElseIf (boolShift And vbCtrlMask) = vbCtrlMask Then
SelectUnSelectGridRow
Else
UnSelectAllGridRows
.Row = last_row_selected
.ColSel = .Cols - 1
.CellBackColor = vbHighlight
.CellForeColor = vbHighlightText
End If
End With
MSHFlexGrid1.Refresh
End Sub
.RowSel属性似乎没有为选择行获取正确的值,结果需要正确选择它所单击的行。
发布于 2019-04-24 20:31:42
在您的网格Click事件中,尝试如下所示:
With MSHFlexGrid1
If .Row = .RowSel Then
.Col = .Cols - 1
.ColSel = 0
End If
End With
您可能还需要在网格控件上设置SelectionMode。如果设置为flexSelectionFree,上面的代码应该可以工作
发布于 2019-04-24 23:33:44
是否设置了SelectionMode
属性?如果没有,您可以通过单击属性窗口中的“自定义”来访问它。这将打开一个对话框,其中SelectionMode
是可用的属性之一。
https://stackoverflow.com/questions/55813677
复制相似问题