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;
标签:ListView1,begin,nFount,Items,findCaption,AItem,end,listview 来源: https://www.cnblogs.com/maweiwei/p/11094964.html