1

データグリッド内のテキストを検索したいのですが、以下のようなコードを書くとエラーになります

For i As Integer = 0 To _dt.Items.Count - 1
            Dim row As DataGridRow = DirectCast(_dt.ItemContainerGenerator.ContainerFromIndex(i), DataGridRow)
            For j As Integer = 0 To _dt.Columns.Count - 1
                If row IsNot Nothing Then
                    Dim cellContent As TextBlock = TryCast(_dt.Columns(j).GetCellContent(row), TextBlock)
                    If cellContent IsNot Nothing AndAlso cellContent.Text.Equals(txtfind.Text) Then
                        _dt.ScrollIntoView(row, _dt.Columns(j))
                        Dim presenter As DataGridCellsPresenter = GetVisualChild(Of DataGridCellsPresenter(row))
                        Dim cell As DataGridCell = DirectCast(presenter.ItemContainerGenerator.ContainerFromIndex(j), DataGridCell)
                        _dt.SelectedItem = cell
                        cell.IsSelected = True
                        row.MoveFocus(New TraversalRequest(FocusNavigationDirection.[Next]))
                        Exit For
                    End If
                End If
            Next
        Next

エラーは行です: 配列境界は型指定子に表示できません。声明:Dim presenter As DataGridCellsPresenter = GetVisualChild(Of DataGridCellsPresenter(row))

ありがたいアビモを助けて

4

1 に答える 1

0

変化する:

   Dim presenter As DataGridCellsPresenter = GetVisualChild(Of DataGridCellsPresenter(row))

'you have created an array with row number of values.

に:

   Dim presenter As DataGridCellsPresenter = GetVisualChild(Of DataGridCellsPresenter)(row)
于 2013-05-28T01:36:18.830 に答える