Search code examples
delphibuttonvclundeclared-identifier

TButton undeclared Identifier


The following code is self created by Delphi which throws an error:

undeclared identifier TButton

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

end;

end.

Since it uses all the units required why does it throw an error?


Solution

  • TButton is defined in Vcl.StdCtrls which is missing from the list of used units. Usually the IDE would add that missing unit to the list when you save the project.