sigalos
asked on
Containing text comparison.
I have this line of code:
if CompareText(sSearch, tvDatabase.Items[i].Text) = 0 then
What I want though is, any letters I type to find the closest match.
Is that possible?
Thank you.
if CompareText(sSearch, tvDatabase.Items[i].Text) = 0 then
What I want though is, any letters I type to find the closest match.
Is that possible?
Thank you.
ASKER
Sorry,
I am scanning through the nodes of a Treeview to find the best possible match with the string I will type in a EditBox.
I am scanning through the nodes of a Treeview to find the best possible match with the string I will type in a EditBox.
Can you define "best possible match"?
Are there any rules as to which string matches "better" than others?
Are there any rules as to which string matches "better" than others?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very Good.
By the way, I like your site.
Thank you.
By the way, I like your site.
Thank you.
Cheers mate.
John.
John.
If u want a effect just like Internet Explorer has on its Address combobox u can use this to fill your combo with the closest match as u type:
This is really cool!
procedure Tform1.Combobox1Enter(Send
begin
autopreencher := true;
end;
procedure Tform1.Combobox1Change(Sen
var
tam,cont : integer;
begin
if autopreencher then with (sender as Tcombobox) do
begin
tam := length(text);
for cont := 0 to items.Count - 1 do
if 0=ansicomparetext(text,cop
begin
text := items.strings[cont];
selstart := tam;
sellength := length(text);
break;
end;
end;
end;
procedure Tform1.Combobox1KeyPress(S
var
prox : boolean;
begin
with (sender as tcombobox) do
begin
Autopreencher := true;
prox := false;
case ord(key) of
vk_return : begin
selstart := length(text);
sellength := 0;
key := #0;
DroppedDown := false;
Prox := true;
end;
vk_back : Autopreencher := false;
end;
if (not Autopreencher) and (SelText <> '') then
begin
text := copy(text,1,selstart);
selstart := length(text);
sellength := 0;
key := #0;
end;
end;
if prox then findnextcontrol(sender as tcombobox,true,true,false)
end;
If U want to type in a edit and find the closest match inside a database, Sure it's possible!
U can use SQL to do the task and a Grid to show the results
With Query1 do
begin
close;
sql.clear;
sql.add('Select * from MYTABLENAME where UPPER(MYFIELDNAME) LIKE UPPER(''%'' + MYPARAMETERNAME +''%'')')
params.parambyname('MYPARA
end;
in this SQL code the ''%'' works as a wildcard and finds any string containing the string u typed
VSF
www.enge.cjb.net
www.victory.hpg.com.br