所以我正在处理的VB6项目中有FlexGrid。它在每一行上都有名称,并且我有一个下拉列表,因此用户可以选择想要查看其更多信息的名称,这就是我的名称。
Dim target_name As String
Dim r As Integer
' Get the name.
target_name = Combo1
If Len(target_name) = 0 Then Exit Sub
' Search for the name, skipping the column heading row.
target_name = LCase$(target_name)
For r = 1 To MSFlexGrid1.Rows - 1
If LCase$(MSFlexGrid1.TextMatrix(r, 0)) = _
target_name Then
' We found the target. Select this row.
MSFlexGrid1.Row = r
MSFlexGrid1.RowSel = r
MSFlexGrid1.Col = 0
MSFlexGrid1.ColSel = MSFlexGrid1.Cols - 1
' Make the row visible.
MSFlexGrid1.TopRow = r
Exit Sub
End If
Next r
效果很好,但是它也显示了该名称下的所有内容,我希望它仅列出所选名称。任何帮助都会很棒。
您的网格的数据源是什么?您可以将过滤器放在数据网格数据源上,以便当用户从下拉列表中选择名称时,只有选定人员的详细信息才从数据源返回到网格。不完全是您的要求,而是我如何实现您想要的结果。
P.S。我在vb6中使用过flexgrid,但我不知道一种方法来完成您在网格上的要求(可能在那里,但我从未注意到)。