Searching a dbgrid

01-14-2004, 10:08 AM
I have a dbgrid and I need to be able to search the records in the grid and have the record it found highlighted and then be able to find the next record.
Can anyone help point me in the right direction.


01-14-2004, 10:18 AM

I might be not original with my answer, but if you can then switch to using FlexGrid control which is far more user friendly and flexible in my view


Dennis DVR
01-14-2004, 10:24 AM
well just in case how did you populate your grid?

01-15-2004, 08:11 PM
Im using a Data control to populate my grid.

01-16-2004, 12:25 AM
before using dbgrid you must bind dbgrid to a adodc.
and if you use adodc answer of your question is to easy.
code :

adodc1.Recordset.Find "ISIRALAMA=" & str(siralama_id_asagidaki)

(ISIRALAMA is a field)

the cursor of adodc1 goes to the record you want to find. and then dbgrid is highlight the this record (because dbgrid was connected to adodc1).

good luck

Dennis DVR
01-16-2004, 03:59 AM
try this code

'this is the code for searching of string
adodc1.recordset.find "Field1 ='" & whattofind & "'"
if not Adodc1.Recordset.eof then
'this is the code for selection
Datagrid1.SeBookMarks.Add adodc1.Recordset.Bookmark
end if

ps: if you want to un-select the selected row
you can use the datagrid1.selbookmarks.remove but you need to loop through the selbookmarks

note : not tested

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum