Oliver
  • Oliver
  • Advanced Member Topic Starter
2013-11-28T09:52:26Z
While FindSearchMatchRow() is certainly valuable, I miss being able to search backwards (up), also to search by row instead of column and ultimately search the entire grid row by row.

I can search the grid by looping throuch the columns and using FindSearchMatchRow() on each one but thats not a natural search order for our data.

If you consider doing any more work on the ActiveX-Control, this would be something.

(We newly aquired iGrid for use in our MSAccess Projects. These are some things i found. I will post each one in a seperate topic, so they can be tracked easily)

Regards,
Oliver
McLoo
2013-11-29T08:37:23Z
i'd really second a more powerful search feature.

currently i need to do some looping to find a matching ROW

where vLastSelectedCells is an array of the cell values i search for.


引用:

Dim lastFoundRow As Long
Dim bRowfound As Boolean
lastFoundRow = .FindSearchMatchRow(1, vLastSelectedCells(0))
bRowfound = True

For i = 1 To UBound(vLastSelectedCells)
If lastFoundRow <> .FindSearchMatchRow(i + 1, vLastSelectedCells(i), lastFoundRow) Then
bRowfound = False
Exit For
End If
Next

If bRowfound Then
.CurRow = lastFoundRow
End If



any better solution?
Oliver
  • Oliver
  • Advanced Member Topic Starter
2013-11-29T09:02:37Z
If I understand correctly, you are looking to find a specific row where you have all column values in the vLastSelectedCells array, right? You are probably doing this to select the row again, after it's position changes for some reason. This is a scenario we have, too.

Since our data comes from a database, we usually have a unique ID for the row in question or can easily build one in the query. Then you need to do just ONE .FindSearchMatchRow on that (invisible) key-column to get the correct row.
An alternative approach can be to build that key when you are populating your grid. You are probably looping through all the rows anyway and this is a good spot to concatenate some key columns with a separator and put that value into the ID column. To do the search, you just concatenate the values the same way and do a single search.

So for each lRow, something like this should do the trick:

.CellValue(lRow, "ID") = .CellValue(lRow, "col1") + "|" + .CellValue(lRow, "col2") + "|" + .CellValue(lRow, "col3")

to look it up:

iFoundRow = .FindSearchMatchRow("ID", Join(sLastSelectedKey, "|"))

setting sLastSelectedKey is easier, too, because you just need to query

sLastSelectedKey = .CellValue(lRow, "ID")

in the CurCellChange-Event.

Regards,
Oliver