내가 참조하는 장치를 선호하기 때문에 여기에 도움이 될 것입니다. Form2
에는 Form2
이 표시되기 전에 Form1
에서 목록보기가 할당 된 public 속성 TargetListView
이 선언됩니다. 이제 범위 Form2
에서 Form1
목록보기에 액세스 할 수 있으며 항목을 닫으면 해당 항목을 복사 할 수 있습니다. 여기
은 제 1 유닛에 대한 단순화 된 코드이다 :
unit Unit1;
uses
Unit2;
type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2 := TForm2.Create(Self);
Form2.TargetListView := ListView1;
Form2.Show;
end;
그리고 여기서 상기 제 2 유닛에 대한 단순화 된 코드이다 :
unit Unit2;
type
TForm2 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
TargetListView: TListView;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
I: Integer;
begin
TargetListView.Items.BeginUpdate;
try
for I := 0 to ListView1.Items.Count - 1 do
TargetListView.Items.Add.Assign(ListView1.Items[I]);
finally
TargetListView.Items.EndUpdate;
end;
Close;
end;
[파스칼로 mainform에서리스트 뷰를 전달
정확한 중복 비 모드 양식] (http://stackoverflow.com/questions/10095001/pascal-passing-a-listview-from-mainform-to-a-nonmodal-form). – TLama