unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls;
type
TForm1 =
class(TForm)
ListView1: TListView;
Button1: TButton;
Label1: TLabel;
procedure ListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
ListViewInUpdate : Boolean;
procedure UpdateLabel;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
if not ListViewInUpdate
then
UpdateLabel;
end;
procedure TForm1.UpdateLabel;
begin
if (ListView1.Items.Count > 0)
AND
(ListView1.Items.Item[0].SubItems.Count > 0)
then
Label1.Caption := ListView1.Items.Item[0].SubItems.strings[0];
end;
procedure TForm1.Button1Click(Sender: TObject);
var Eintrag : TListItem;
begin
ListViewInUpdate := true;
Eintrag := ListView1.Items.Add;
Eintrag.Caption := '
ok';
Eintrag.SubItems.Add('
geht');
ListViewInUpdate := false;
UpdateLabel;
end;
end.