1

所以我在我正在处理的 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

这很好用,但它也显示了该名称下方的所有内容,我希望它只挑出选定的名称。任何帮助都会很棒。

4

1 回答 1

1

您的网格的数据源是什么?您可以将过滤器放在数据网格数据源上,这样当用户从下拉列表中选择名称时,只有选定的人员详细信息会从数据源返回到网格。不完全是您所要求的,而是我将如何实现您想要的结果。

PS 我在 VB6 中使用过 FlexGrid,但我不知道如何在网格上执行您所要求的操作(可能在那里,但我从未注意到它)。

于 2010-04-16T20:19:30.680 回答