Page 1 of 1

Datagrid Search

Posted: Wed Aug 28, 2013 1:13 pm
by Gautami
Hi everyone,

I have a datagrid form with each row having 3 text fields.
It is taking in data from a sqlite file.
I also have a search box.
I would like to type a query into the search box and have it highlight every
instance it appears in the datagrid. I also want to count the number of times if occurs.

The find command works for only the data that is visible on the card. When i scroll down, I have to re enter text in the search box to find the next instance of the word I am looking for. Is there any other way I can achieve my objective?

Thank you.
Regards,
Gautami

Re: Datagrid Search

Posted: Wed Aug 28, 2013 7:29 pm
by Simon
Hi Gautami,
This isn't exactly what you asked for but it may help:
http://quartam.blogspot.com/2010/07/dat ... ample.html

Simon

Re: Datagrid Search

Posted: Fri Aug 30, 2013 6:25 pm
by Gautami
Hi Simon,
Thank you!
I will look into this :)

Thanks for helping.

G

Re: Datagrid Search

Posted: Fri Aug 30, 2013 7:13 pm
by dunbarx
You can always put the dgText of your DG into a variable, and do a search for your text with something like

Code: Select all

function revFullFind tText,tFind,exactly --RETURNS LINE NUMBER & "," & WORD NUMBER
   put 0 into counter
   switch exactly
      case "true"
      case empty
         repeat for each line tline in tText
            add 1 to counter
            if tFind = tline then
               put counter & return after tResult
            end if
         end repeat
         break
      case "false"
         repeat for each line tline in tText
            add 1 to counter
            if tFind is in tline then
               repeat with y = 1 to the number of words in tLine
                  if word y of tLine = tFind then put y & "," after temp
               end repeat
               delete last char of temp
               put counter & "," & temp & return after tResult
               put "" into temp
            end if
         end repeat
         break
   end switch
   return tResult
end revFullFind
This will give a list of the line numbers that either contain your text or equal it. You can then go back to the DG and set the DGHilitedLiines.

Craig Newman