PDA

View Full Version : Delphi Procedure problems


mw2005
02-23-2008, 05:27 PM
Hi,

The following are compiler errors:

[Error] Unit1.pas(31): Undeclared identifier: 'ListView1'
[Error] Unit1.pas(33): Undeclared identifier: 'Caption'
[Error] Unit1.pas(34): Undeclared identifier: 'SubItems'
[Error] Unit1.pas(35): Missing operator or semicolon
[Error] Unit1.pas(41): Not enough actual parameters
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'

It works fine when it is in form create but in its own procedure it does not seem to work.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ToolWin, ComCtrls;

type
TForm1 = class(TForm)
ListView1: TListView;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure populatetable;
begin
with ListView1.Items.Add do
begin
Caption := 'An Item (First Column)';
SubItems.Add('Second Column');
SubItems.Add('Third Column');
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
populatetable;
end;

end.

fthctn
08-09-2010, 01:28 PM
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ToolWin, ComCtrls;

type
TForm1 = class(TForm)
ListView1: TListView;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure populatetable;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.populatetable;
begin
with ListView1.Items.Add do
begin
Caption := 'An Item (First Column)';
SubItems.Add('Second Column');
SubItems.Add('Third Column');
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
populatetable;
end;

end.

its too late for answer the question but maybe helps to other people's :rolleyes: