1.比如一个单元格内,图片在上面,其下方是图片名,最重要一点的是,同时要求该单元格的高度能自动调整。如何实现,求高手帮忙。

解决方案 »

  1.   

    一个单元格里显示两个元素,只能自画了自动适应调试,可以在OnGetCellHeight事件中自己计算
      

  2.   

    怎么貌似我在cb版见过类似的帖子图片下面画好文字,再把图片画到单元格里,自适应高度按LS说的
      

  3.   

    单元格高度自动调整可以设置                   
    tvcxgrd1DBTableView1.OptionsView.CellAutoHeight:=True
    图片话设置cxgrdbclmntvcxgrd1DBTableView1.Properties的属性为Image
    文字显示 自己画把
      

  4.   

    有没有熟悉devexpress的 cxgrid,来指导一下。
      

  5.   


    procedure TForm1.tvGrid1DBTableView1CustomDrawCell(
      Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
    var
      AEditValue: Variant;
      APicture: TPicture;
      FBounds:TRect;
    begin
      cxgrdbclmnGrid1DBTableView1IconImage.Options.Focusing:=False; //点上去图标不变
      if AViewInfo.Item <> cxgrdbclmnGrid1DBTableView1IconImage then
      begin
        Exit;
      end;
      AEditValue := AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1IconImage.Index];
      if VarIsStr(AEditValue) or VarIsArray(AEditValue) then
      begin
        APicture := TPicture.Create;
        try
          LoadPicture(APicture,
            TcxImageProperties(cxgrdbclmnGrid1DBTableView1IconImage.Properties).GraphicClass, AEditValue);
          APicture.Bitmap.Canvas.Brush.Style:=bsClear;
          APicture.Bitmap.Canvas.TextOut(10,40,AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1CName.Index]);   //文本显示的位置 自己根据需要调整把
          FBounds:=AViewInfo.Bounds;
          ACanvas.FillRect(FBounds);
          ACanvas.DrawComplexFrame(FBounds,   clBtnHighlight,   clBtnShadow,   [bBottom,   bLeft,   bRight],   1);
          InflateRect(FBounds,   -1,   -1);
          ACanvas.Font.Color   :=   clBlack;
          ACanvas.Brush.Style   :=   bsClear;
          ACanvas.DrawGlyph(FBounds.Left,FBounds.Top,APicture.Bitmap);
        finally
          APicture.Free;
        end;
      end;
      ADone:=True;
    end;