Menambahkan Image pada Combo Box

Posted by @MINS

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, StdCtrls;

type
TForm1 = class(TForm)
ImageList1: TImageList;
ComboBox1: TComboBox;
procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.FillRect(Rect);
ImageList1.Draw(ComboBox1.Canvas,Rect.Left,Rect.Top,Index);
ComboBox1.Canvas.TextOut(Rect.Left+ImageList1.Width+2,Rect.Top,
ComboBox1.Items[Index]);
end;

end.

1 comments:

mmm said...

Assalamualaikum..

Referensi project2 delphi silahkan kunjungi blog saya :
http://energi08pnup.blogspot.com/
mungkin sya bisa membantu..

Smoga bermanfaat

Post a Comment