Pesquisa em MEMO ! COMO ?
Como fazer pesquisa em um MEMO via um EDIT ?
Rodrigo!
Rodrigo!
Ropesca
Curtidas 0
Respostas
Anonymous
17/02/2003
este exemplo é para um Rich..mas, deve funcionar para um memo
var
i : integer;
aux: integer;
begin
aux:=1;
for i:=0 to Length(RichEdit1.Text) do
begin
if (Copy(RichEdit1.Text,i+1,length(Edit1.Text)) =
Edit1.Text) then
begin
RichEdit1.SelStart := aux;
RichEdit1.SelLength := i-aux+1;
RichEdit1.SelAttributes.Color := ClBlack;
RichEdit1.SelAttributes.Style := [];
RichEdit1.SelStart := i;
RichEdit1.SelLength := Length(Edit1.text);
RichEdit1.SelAttributes.Color := ClRed;
RichEdit1.SelAttributes.Style := [fsBold];
aux := i + length(Edit1.Text);
end;
end;
RichEdit1.SelStart := aux;
RichEdit1.SelLength := i-aux+1;
RichEdit1.SelAttributes.Color := ClBlack;
RichEdit1.SelAttributes.Style := [];
end;
var
i : integer;
aux: integer;
begin
aux:=1;
for i:=0 to Length(RichEdit1.Text) do
begin
if (Copy(RichEdit1.Text,i+1,length(Edit1.Text)) =
Edit1.Text) then
begin
RichEdit1.SelStart := aux;
RichEdit1.SelLength := i-aux+1;
RichEdit1.SelAttributes.Color := ClBlack;
RichEdit1.SelAttributes.Style := [];
RichEdit1.SelStart := i;
RichEdit1.SelLength := Length(Edit1.text);
RichEdit1.SelAttributes.Color := ClRed;
RichEdit1.SelAttributes.Style := [fsBold];
aux := i + length(Edit1.Text);
end;
end;
RichEdit1.SelStart := aux;
RichEdit1.SelLength := i-aux+1;
RichEdit1.SelAttributes.Color := ClBlack;
RichEdit1.SelAttributes.Style := [];
end;
GOSTEI 0