在我的Delphi窗體中,我有一個ImageList和4張圖片。還有一個名爲ComboBox1
的組合框和一個名爲Image9
的TImage組件。使用組合框加載TImage中的ImageList圖片
我爲我的ComboBox創建了一個onChange
,因爲我想要做這樣的事情:如果選擇了ComboBox項目1,然後在我的ImageList中加載圖像1。如果選擇ComboBox項目3(例如),則爲相同的情況,則加載ImageList的圖像3。
我寫的代碼是這樣的:
case ComboBox1.Items[ComboBox1.ItemIndex] of
0:
begin
ImageList1.GetBitmap(0,Image9.Picture);
end;
1:
begin
ImageList1.GetBitmap(1,Image9.Picture);
end;
2:
begin
ImageList1.GetBitmap(2,Image9.Picture);
end;
3:
begin
ImageList1.GetBitmap(3,Image9.Picture);
end;
end;
有了這個代碼,該IDE(我用Delphi XE4)是給我一個錯誤的case ComboBox1.Items[ComboBox1.ItemIndex] of
,因爲它說,有序類型是必需的。我能做什麼?
case ComboBox1.ItemIndex of – Darthman