- Код: Выделить всё
- type
 TNodeItem = class(TListItem)
 public
 parent: TNodeItem;
 i, j: Integer;
 end;
 var
 test:TNodeItem;
 test:=TNodeItem.Create();
Что не так-то? Что указывать в скобках?
Модератор: Модераторы
type
TNodeItem = class(TListItem)
public
    parent: TNodeItem;
    i, j: Integer;
end;
var
test:TNodeItem;
test:=TNodeItem.Create();unit Unit1; 
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
  StdCtrls;
type
  { TForm1 }
  TForm1 = class(TForm)
    Button1: TButton;
    ListView1: TListView;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 
type
TNodeItem = class(TListItem)
public
    parent: TNodeItem;
    i, j: Integer;
end;
var
  Form1: TForm1; 
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var T:TNodeItem;
begin
    T:=TNodeItem.Create(ListView1.Items);
    T.Caption:='adf';
    ListView1.Items.AddItem(T);
end;
end.
constructor Create(AOwner: TListItems);
unit Unit1; 
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
  StdCtrls;
type
  { TForm1 }
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    ListView1: TListView;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 
type
TNodeItem = class(TListItem)
public
    parent: TNodeItem;
    i, j: Integer;
end;
var
  Form1: TForm1;
  TNodeItemList:TList;
  AOwner: TListItems;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var T:TNodeItem;
    I:Integer;
begin
    if TNodeItemList = nil then
    TNodeItemList:=TList.Create;
    if AOwner = nil then
      AOwner:=TListItems.Create(Nil);
    T:=TNodeItem.Create(AOwner);
    T.Caption:=IntToStr(TNodeItemList.Count);
    //ListView1.Items.AddItem(T);
    TNodeItemList.Add(T);
end;
procedure TForm1.Button2Click(Sender: TObject);
var I:Integer;
    T:TNodeItem;
begin
  if TNodeItemList = nil then exit;
  For I:=0 to TNodeItemList.Count-1 do
    begin
      T:=TNodeItem(TNodeItemList.Items[I]);
      if T <> Nil then
        Memo1.Lines.Add(T.Caption);
    end;
end;
end.
    T:=TNodeItem.Create(Nil);
    T.Caption:='adf';
T.Caption:=IntToStr(TNodeItemList.Count);TNodeItem = class(TListItem)
public
    parent: TNodeItem;
    i, j: Integer;
end;      parent:=Nil;
    i:=0;
   j:=0;
TNodeItem = class(TListItem)
public
    PToParent: ^TNodeItem;
    i, j: Integer;
end;  Sniper писал(а):В том то и дело что у меня нет и не будет ListView...
Мне нужен TList и вот такой TListItem.
TListItem - the ancestor class for the Items in TCustomListView and TListView
TListItem - класс-предок элементов (Items) TCustomListView и TListView.
TNodeItem = class
public
    parent: TNodeItem;
    i, j: Integer;
end;
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1