unction Copy(S; Index, Count: Integer): string;
function Copy(S; Index, Count: Integer): array;
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);var
Found: boolean;
i,SelSt: Integer;
TmpStr: string;
begin
{ first, process the keystroke to obtain the current string }
{ This code requires all items in list to be uppercase}
if Key in ['a'..'z'] then Dec(Key,32); {Force Uppercase only!}
with (Sender as TComboBox) do
begin
SelSt := SelStart;
if (Key = Chr(vk_Back)) and (SelLength <> 0) then
TmpStr := Copy(Text,1,SelStart)+Copy(Text,SelLength+SelStart+1,255) else if Key = Chr(vk_Back) then {SelLength = 0}
TmpStr := Copy(Text,1,SelStart-1)+Copy(Text,SelStart+1,255)
else {Key in ['A'..'Z', etc]}
TmpStr := Copy(Text,1,SelStart)+Key+Copy(Text,SelLength+SelStart+1,255);
if TmpStr = '' then Exit;
{ update SelSt to the current insertion point } if (Key = Chr(vk_Back)) and (SelSt > 0) then Dec(SelSt) else if Key <> Chr(vk_Back) then Inc(SelSt);
Key := #0; { indicate that key was handled }
if SelSt = 0 then
begin
Text:= '';
Exit;
end; {Now that TmpStr is the currently typed string, see if we can locate a match } Found := False;
for i := 1 to Items.Count do
if Copy(Items[i-1],1,Length(TmpStr)) = TmpStr then
begin
Text := Items[i-1]; { update to the match that was found }
ItemIndex := i-1;
Found := True;
Break;
end;
if Found then { select the untyped end of the string }
begin
SelStart := SelSt;
SelLength := Length(Text)-SelSt; end
else Beep;
end;
end;
//这是帮助上的例子,怎么不自己找呢?
function Copy(S; Index, Count: Integer): array;
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);var
Found: boolean;
i,SelSt: Integer;
TmpStr: string;
begin
{ first, process the keystroke to obtain the current string }
{ This code requires all items in list to be uppercase}
if Key in ['a'..'z'] then Dec(Key,32); {Force Uppercase only!}
with (Sender as TComboBox) do
begin
SelSt := SelStart;
if (Key = Chr(vk_Back)) and (SelLength <> 0) then
TmpStr := Copy(Text,1,SelStart)+Copy(Text,SelLength+SelStart+1,255) else if Key = Chr(vk_Back) then {SelLength = 0}
TmpStr := Copy(Text,1,SelStart-1)+Copy(Text,SelStart+1,255)
else {Key in ['A'..'Z', etc]}
TmpStr := Copy(Text,1,SelStart)+Key+Copy(Text,SelLength+SelStart+1,255);
if TmpStr = '' then Exit;
{ update SelSt to the current insertion point } if (Key = Chr(vk_Back)) and (SelSt > 0) then Dec(SelSt) else if Key <> Chr(vk_Back) then Inc(SelSt);
Key := #0; { indicate that key was handled }
if SelSt = 0 then
begin
Text:= '';
Exit;
end; {Now that TmpStr is the currently typed string, see if we can locate a match } Found := False;
for i := 1 to Items.Count do
if Copy(Items[i-1],1,Length(TmpStr)) = TmpStr then
begin
Text := Items[i-1]; { update to the match that was found }
ItemIndex := i-1;
Found := True;
Break;
end;
if Found then { select the untyped end of the string }
begin
SelStart := SelSt;
SelLength := Length(Text)-SelSt; end
else Beep;
end;
end;
//这是帮助上的例子,怎么不自己找呢?
解决方案 »
- ★当RichEdit1里边的文字增多,直到出现滚动条;当出现滚动条时候,我如何得到这个事件??
- cxDateEdit的日期为什么总是改变不了呢?
- image背景透明的问题(Transparent设为true,然后点Picture装载一bmp图像,bmp图像背景色自动去掉,但在程序中用LoadFromFile装载bmp,bmp的背
- 发现delphi和netmeeting同时运行的冲突问题
- 请教:这样的ComboBox如何实现,帮忙啊,UP有分
- 如何高速采样
- 用这个程序2个小时就可以给出300分,送出源代码,请到sunyuzhe.363.net下载
- 学DELPHI数据库编成,有那些好书?急需!
- 急!!!有沒有什么可以輕松編輯HTML或Rich格式文檔的控件?
- 一个比较头痛的问题
- 小问题:怎样在DBGrid里生成计算列?
- 有谁熟悉联通的H2接口,能简要介绍一下吗?
copy(astring,1,3);的值为从第一位开始取,取三位为'abc'