用TDrawGrid,自己往上画,我有做过,比较好实现的,然后根据点击的位置,打开大图就可以了。<br><br>使用DRAWgrid时,在DrawGrid1DrawCell事件中,可以调用如下的函数,画上图片,以及文字,以及实现选中后,文字蓝色显示的功能。<br>Procedure MyDrawGridCell(Sender: TObject; Rect: TRect; State: TGridDrawState;<br> Bmp:TBitmap; ShowWords:String; Pos:Integer; TxtHeight:Integer);<br>var<br> BmpRect:TRect;<br> x,y:Integer;<br>begin<br> with TDrawGrid(Sender).Canvas do begin<br> Brush.Color := clWhite;<br> FillRect(Rect); //清空<br> if StrisEmpty(ShowWords) and (Bmp=nil) then<br> Exit;<br> //居中显示图片<br> BmpRect:=Rect;<br> BmpRect.Bottom:=BmpRect.Bottom-TxtHeight; //预留文字部分空间<br> x:=(BmpRect.Right-BmpRect.Left-Bmp.Width) div 2; //宽度居中数据<br> y:=(BmpRect.Bottom-BmpRect.Top-Bmp.Height) div 2; //高度居中数据<br> BmpRect.Top:=BmpRect.Top+y;<br> BmpRect.Bottom:=BmpRect.Bottom-y;<br> BmpRect.Left:=BmpRect.Left+x;<br> BmpRect.Right:=BmpRect.Right-x;<br> if Bmp <> nil then begin<br> Bmp.Transparent := True;<br> Bmp.TransParentColor := TDrawGrid(Sender).Color;<br> CopyRect(BmpRect,Bmp.Canvas,Bmp.Canvas.ClipRect);<br> end;<br> //画分隔线<br> BmpRect.Bottom:=BmpRect.Bottom+y;<br> Rectangle(Rect.Left,BmpRect.Bottom,Rect.Right,BmpRect.Bottom+1);<br> //写序号<br> if Pos>0 then begin //传递负数表示不显示序号<br> x:=Rect.Left+1;<br> y:=Rect.Top+1;<br> Font.Color:=clBlack;<br> TextOut(x,y,InttoStr(Pos));<br> end;<br> //居中写文字<br> if TextWidth(ShowWords)>(Rect.Right-Rect.Left) then //如果文字太大,要显示省略号<br> showWords:=Copy(ShowWords,1,(Rect.Right-Rect.Left) div TextWidth('A')-3)+'...';<br> x:=Rect.Left+(Rect.Right-Rect.Left-TextWidth(ShowWords)) div 2; //居中显示<br> y:=BmpRect.Bottom+(TxtHeight-TextHeight(ShowWords)) div 2; //居中显示<br> if gdFocused in State then<br> Font.Color:=clBlue<br> else<br> Font.Color:=clBlack;<br> TextOut(x,y,ShowWords);<br> end;<br>end;