0
procedure TMyForm.FormCreate(Sender: TObject);
var
  Group: TListGroup;
  Item: TListItem;
  s1, s2: string;
begin
  ListView1.ViewStyle := vsReport;
  ListView1.GroupView := True;
  ListView1.Columns.Add.Caption := 'My column';
  Group := ListView1.Groups.Add;
  Group.Header := 'My header';
  Group.GroupID := 0;
  Item := ListView1.Items.Add;
  Item.GroupID := 0;
  Item.Caption := 'My item';

end

我将上面的代码复制到我的 RAD Embarcadeo delphi 表单代码中。但是为什么在将上面的代码粘贴到 CODE 选项卡上的适当位置后,我没有在表单上自动获取组件...相反,它给出了许多错误,例如

Undeclared identifier TListGroup at line 27 
Undeclared identifier TListItem at line 28
Undeclared identifier ListView1 at line 31
Undeclared identifier ViewStyle at line 31
Undeclared identifier vsReport at line 31
Undeclared identifier GroupView at line 32
Undeclared identifier TListGroup at line 27
4

1 回答 1

3

您的源表单上有一个ListView1组件,您也应该将其复制到新表单中。从旧表单查看代码时,按F12切换到表单视图。查找并选择ListView1组件,然后复制它。将其粘贴到新表单的表单视图中。当您这样做并保存新表单/代码时,它会将所需的单元添加到uses新代码的子句中。这将解决您的错误。

于 2013-07-03T06:52:56.803 回答