//增加
procedure TForm1.Button1Click(Sender: TObject);
var
lsItem: TListItem;
begin
lsItem := ListView1.Items.Add;
lsItem.Caption := VarToStr(ListView1.Items.Count);
lsItem.SubItems.Add(edit1.Text);
lsItem.SubItems.Add(edit2.Text); edit1.Text := '';
Edit2.Text := '';
end;
//修改
procedure TForm1.Button2Click(Sender: TObject);
begin
ListView1.Selected.SubItems.Strings[] := Edit1.Text;
ListView1.Selected.SubItems.Strings[] := edit2.Text;
end;
//删除
procedure TForm1.Button3Click(Sender: TObject);
begin
ListView1.DeleteSelected;
edit1.Text := '';
Edit2.Text := '';
end;//点击项目取值
procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
begin
edit1.Text := Item.SubItems.Strings[];
Edit2.Text := Item.SubItems.Strings[];
end;
//循环判断Checkbox是否选中
procedure TForm1.Button4Click(Sender: TObject);
var
i: Integer;
begin
memo1.Clear;
for i := to ListView1.Items.Count - do
begin
if ListView1.Items.Item[i].Checked then
begin
memo1.Lines.Add(ListView1.Items.Item[i].Caption);
memo1.Lines.Add(ListView1.Items.Item[i].SubItems.Strings[]);
memo1.Lines.Add(ListView1.Items.Item[i].SubItems.Strings[]);
end; end;
end;