【发布时间】:2013-07-24 22:04:47
【问题描述】:
在我的 Delphi 表单中,我有一个带有 4 张图片的 ImageList。还有一个名为ComboBox1 的ComboBox 和一个名为Image9 的TImage 组件。
我为我的 ComboBox 创建了一个onChange,因为我想做这样的事情:如果选择了 ComboBox 项目 1,则将图像 1 加载到我的 ImageList 中。如果选择了 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 上给我一个错误,因为它说需要 Ordinal 类型。我能做什么?
【问题讨论】:
-
case ComboBox1.ItemIndex of
标签: delphi