2013-07-03 20 views
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表單代碼上面的代碼。但是,爲什麼我不能自動在窗體上到合適的位置代碼標籤上面的代碼粘貼後得到 組件... 相反,它是給像如何在Delphi中使用源代碼在窗體上自動獲取對象?

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 
+1

你希望*代碼做什麼?我認爲你對代碼的含義缺乏瞭解,這當然會引出你爲什麼複製它的問題。 –

回答

3

許多錯誤還有就是你的源代碼的形式在ListView1組件你也應該複製到你的新表單。從舊窗體查看代碼時,請按F12切換到窗體視圖。找到並選擇ListView1組件,然後複製它。將其粘貼到新表單的表單視圖中。當你這樣做並保存你的新表單/代碼時,它會將所需的單元添加到新代碼的uses子句中。這將解決你的錯誤。

相關問題