文章目录
combobox中添加位图
提示:这里可以添加技术概要
核心源码
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Style := csOwnerDrawVariable;
//Set height of one item
ComboBox1.ItemHeight := 35;
//load all bitmaps
Bitmap1 := TBitmap.Create;
Bitmap1.LoadFromFile(‘1.bmp’);
Bitmap2 := TBitmap.Create;
Bitmap2.LoadFromFile(‘2.bmp’);
Bitmap3 := TBitmap.Create;
Bitmap3.LoadFromFile(‘3.bmp’);
Bitmap4 := TBitmap.Create;
Bitmap4.LoadFromFile(‘4.bmp’);
//assign bitmaps with item objects - caption of the items: Bitmap 1 - Bitmap 4
ComboBox1.Items.AddObject(‘Bitmap 1’, Bitmap1);
ComboBox1.Items.AddObject(‘Bitmap 2’, Bitmap2);
ComboBox1.Items.AddObject(‘Bitmap 3’, Bitmap3);