ListView

 
添加项目
procedure TForm1.Button1Click(Sender: TObject);
begin
  with listview1.Items do
  begin
     Add.Caption:='1111111';
     Add.Caption:='2111111';
     Add.Caption:='3111111';
  end;
end;
 
 
 
//添加 项目
procedure TForm1.Button3Click(Sender: TObject);
begin
  with ListView2.Items.Add do
  begin
    Caption:='0';
    SubItems.add('FileName1');
    SubItems.add('FileName2');
  end;
end;
 
 
//添加listbox里面的项目
procedure TForm1.Button1Click(Sender: TObject);
var
    i:Integer;
begin
  for i := 0 to ListBox1.Items.Count-1 do
  begin
      listview1.Items.add.Caption:=ListBox1.Items[i];
  end;
end;
 
 
 
 
 
 
添加头
procedure TForm1.Button1Click(Sender: TObject);
begin
  with ListView1 do
  begin
    Columns.Add.Caption:='ID';
    Columns.Add.Caption:='FileName';
    Columns.Add.Caption:='Count';
 
    Columns[0].Width:=50;
    Columns[1].Width:=100;
    Columns[2].Width:=200;
  end;
end;
 
 
//判断是否选中
procedure TForm1.ListView1ContextPopup(Sender: TObject; MousePos: TPoint;
  var Handled: Boolean);
begin
      if ListView1.Selected = nil then
        begin
          a1.Enabled:=False;
        end
      else
          a1.Enabled:=True;
end;
 
 




posted @ 2014-07-29 16:41  XE2011  阅读(158)  评论(0编辑  收藏  举报