如题:
解决方案 »
- 怎么循环读出数据库的数据
- 请问怎么让窗口一启动就隐藏,在任务栏也不显示???
- 如何用quickrep在一页纸中打印一式两份的报表?
- 急!!QuickReport的报表在win98下正常的连续打印,但在WIN2000下每打印完一张,都要走完一张A4纸的长度后才打第二张纸,
- 大侠快救命!帮帮小第!treeview建树问题!
- active form在web上发布的问题,请教各位
- 新手求 DelphiAPI
- 我该选哪个?
- 谁能给出把exe的flash文件还原成swf文件的具体思路或者实现的方法?
- 在DELPHI中用什么函数得到光盘的卷标?
- 模糊查询like如何使用》?
- 如何清空Com端口缓冲区中的数据?是用PurgeComm函数吗?
function Copy(S; Index, Count: Integer): array;DescriptionS is an expression of a string or dynamic-array type. Index and Count are integer-type expressions. Copy returns a substring or subarray containing Count characters or elements starting at S[Index]. The substring or subarray is a unique copy (that is, it does not share memory with S, although if the elements of the array are pointers or objects, these are not copied as well.)If Index is larger than the length of S, Copy returns an empty string or array.If Count specifies more characters or array elements than are available, only the characters or elements from S[Index] to the end of S are returned.Note: When S is a dynamic array, you can omit the Index and Count parameters and Copy copies the entire array.
The following example shows how to complete partial strings typed into a combo box. The code represents the OnKeyPress event handler of the combo box, which performs most of the default keystroke handling before finding a matching list item and updating the text. Note: This OnKeyPress event handler does not deal with the case when the user types the Delete key. That case must be caught in the OnKeyDown event handler instead.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;
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————