listview findCaption

procedure TfrmCaoZYGLNew.edt1KeyPress(Sender: TObject; var Key: Char);
var
AItem: TListItem;
i: Integer;
isFound: Boolean;
begin
if key = #13 then
begin

AItem := ListView1.FindCaption(nFount, Trim(edt1.Text), True, False, true);

if not Assigned(AItem) then
begin
isFound := False;
for i := 0 to ListView1.Items.Count - 1 do
begin
if Trim(edt1.Text) = ListView1.Items.Item[i].SubItems[0] then
begin
nFount := 0;
isFound := True;
ListView1.Selected := ListView1.Items[i];
ListView1.Items[i].MakeVisible(True); //定位后显示出来
Break;
end
else if (i = ListView1.Items.Count - 1) and not isFound then
begin
MSGWarning('没有找到该操作员');
nFount := 0;
Break;
end;
end;
end
else
begin
ListView1.Selected := AItem;
AItem.MakeVisible(True); //定位后显示出来
if ListView1.Selected.Caption = Trim(edt1.Text) then
nFount := 0
else
nFount := ListView1.Selected.Index;
end;

ListView1.SetFocus;
end;
end;

上一篇:Delphi Tlistview[2] 常用方法和技巧


下一篇:监听webbrowser所有请求(含 js/css/flash/ajax 等请求) 附完整源码