Hello everyone,
I’m new to Lazarus (And Pascal) and i think i have an easy problem, but since I’m new, I have no idea how to fix it.
I’m trying to make an application for a database made in Firebird, so I have a TZConnection (I'm using Zeos), my TZQuery, which is a select * from table, and my TDataSource linked to my TZQuery.
My problem is filtering of a grid with the help of an editbox.
I want to filter the grid, with what I type into the editbox, so when I type in someting like "LAZ", the grid only shows the records with "LAZ" in the field I’m searching in, foe example, a record with LAZARUS in the text.
So I’m thinking of an onchange event for the editbox, but after that I’m lost.
sourcecode could be handly.
How do you filter your dbgrid (actually dataset) in your code.
Do you recall the query with a where clause or with the property filter?
procedure TForm1.Edit1Change(Sender: TObject); begin if Trim(Edit1.Text) <> '' then begin if not SQLQuery1.Filtered then SQLQuery1.Filtered := True; SQLQuery1.Refresh; end else SQLQuery1.Filtered := False; end; procedure TForm1.SQLQuery1FilterRecord(DataSet: TDataSet; var Accept: Boolean); begin Accept := Pos(UpperCase(Edit1.Text), UpperCase(DataSet.FieldByName('YOURFIELD').AsString)) > 0; end;
p.s. Again. Where should I study to get that far?Trying, practising, reading....
....
I did someting like this:...
... DClientes.SQL.Add('where upper(NOME) like :BUSCAR'); ...