У меня есть массив с строками.(максимальная длина строки 8 символов, минимальная длина 3 символа). Также есть stringgrid в который я вписываю текст. Текст я вписываю в каждую строку в одном столбце. Нужно сделать, чтобы при совпадении введенного текста с элементом массива он отобразился в списке, будь это combobox или listbox, без разницы. Проверка ввода по событию SetEditText. Вот что успел сделать. cmd - массив. В массиве строки в верхнем регистре все. Помогите дописать.
procedure TFMain.ComboBox1Change(Sender: TObject);
begin
//edit1.Text:=IntToStr(length(combobox1.Text));
showcombo(combobox1.Text);
end;
procedure TFMain.SGmainSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: string);
var s1, s2,str:string; i,row,crow,ccol,top,left,width,x,y :integer;r:trect;
begin
R := SGMain.CellRect(ACol, ARow);
R.Left := R.Left + SGMain.Left;
R.Right := R.Right + SGMain.Left;
R.Top := R.Top + SGMain.Top;
R.Bottom := R.Bottom + SGMain.Top;
ComboBox1.Left := R.Left + 1;
ComboBox1.Top := R.Top + 1;
ComboBox1.Width := (R.Right + 1) - R.Left;
ComboBox1.Height := (R.Bottom + 1) - R.Top;
ComboBox1.Visible := True;
combobox1.SetFocus;
combobox1change(FMain);
//combobox1.Text:=SGMain.Cells[acol,arow];
//edit1.Text:=combobox1.Text;
//Edit1.Text:=IntToStr(length(str));
//showcombo(str);}
end;
procedure TFMain.showcombo(text: string);
var i,len,c:integer;b,s:string;
begin
addcombo;
len:=length(text);
//Edit1.Text:=IntToStr(len);
for i:= 0 to 231 do begin
b:=combobox1.Items[i];
if length(b)>=len then begin
s:='';
for c := 1 to len do
s:=s+b[c];
if s<>AnsiUpperCase(text) then combobox1.Items[i]:='';
end;
end;
combobox1.Items.Clear;
{if (Value='') then begin
setAll('',Arow);
end
else begin
for i:=Low(cmd) to High(cmd) do begin
if cmd[i,1]=AnsiUpperCase(Value) then begin
SGmain.Cells[1,Arow]:=cmd[i,1];
setAll(cmd[i,0],Arow);
end;end;
end;}
end;
procedure TFMain.addcombo;
var i:integer;
begin
for i:= 0 to 231 do
combobox1.Items.Add(cmd[i,1]);
end;