Tips trik Delphi - Image pada ComboBox
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ImgList, StdCtrls;
type
TForm1 = class(TForm)
ImageList1: TImageList;
theCombo: TComboBox;
procedure theComboDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure theComboChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.theComboDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
theCombo.Canvas.FillRect(Rect);
ImageList1.Draw(theCombo.Canvas,Rect.Left,Rect.Top,Index);
theCombo.Canvas.TextOut(Rect.Left+ImageList1.Width+2,Rect.Top,
theCombo.Items[Index]);
end;
end.
Tidak ada komentar:
Posting Komentar