下面的程序可以在StringGrid中显示ImageList中的图形,不过是Bmp的格式,
您可以编程转换一下就行了
使用TStringGrid的OnDrawCell事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;Rect: TRect; State: TGridDrawState);
var
index: integer;
begin
//确定从ImageList中的图形的索引号
index := ARow * (Sender as TStringGrid).ColCount + ACol; with Sender as TStringGrid do
begin
//填充背景
Canvas.Brush.Color := clBackGround;
Canvas.FillRect(Rect); //把imageList的图形显示在StringGrid中
ImageList1.Draw(Canvas,Rect.Left,Rect.Top,index); if gdFocused in State then
Canvas.DrawFocusRect(Rect);
end;
您可以编程转换一下就行了
使用TStringGrid的OnDrawCell事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;Rect: TRect; State: TGridDrawState);
var
index: integer;
begin
//确定从ImageList中的图形的索引号
index := ARow * (Sender as TStringGrid).ColCount + ACol; with Sender as TStringGrid do
begin
//填充背景
Canvas.Brush.Color := clBackGround;
Canvas.FillRect(Rect); //把imageList的图形显示在StringGrid中
ImageList1.Draw(Canvas,Rect.Left,Rect.Top,index); if gdFocused in State then
Canvas.DrawFocusRect(Rect);
end;
OnDrawCell事件
还有例子呢!!