EhLib.Com https://forum.ehlib.com/en/ |
|
Two images in the cell from grid https://forum.ehlib.com/en/viewtopic.php?f=5&t=1037 |
Page 1 of 1 |
Author: | alextenei [ 30 Mar 2020, 21:28 ] | ||
Post subject: | Two images in the cell from grid | ||
Hello! Exist the possibility of put on two image in one cell/column from grideh? According the image to the attachment. Thank's...
|
Author: | EhLibSupport [ 03 Apr 2020, 18:37 ] | ||||
Post subject: | Re: Two images in the cell from grid | ||||
Hello There are no special properties in the grid to configure the display of multiple images in cells. But you can easily implement this in the Column.OnAdvDrawDataCell event. Here is sample code for the event and a demo project. Code: // ColumnEh.OnAdvDrawDataCell event handler
procedure TForm1.DBGridEh1Columns1AdvDrawDataCell(Sender: TCustomDBGridEh; Cell, AreaCell: TGridCoord; Column: TColumnEh; const ARect: TRect; var Params: TColCellParamsEh; var Processed: Boolean); var ImageIndices: TIntegerDynArray; begin Sender.DefaultDrawColumnDataCell(Cell, AreaCell, Column, ARect, Params); ImageIndices := GetImages(); DrawImages(ImageIndices, ARect); Processed := True; end; //Get array of image Indices from ImageList1 function TForm1.GetImages(): TIntegerDynArray; var f: TField; len: Integer; begin SetLength(Result, 0); len := 0; f := MemTableEh1.FieldByName('Area'); if (f.AsInteger > 10000) then begin SetLength(Result, len+1); Result[len] := len; len:= len+ 1; end; if (f.AsInteger > 100000) then begin SetLength(Result, len+1); Result[len] := len; len:= len+ 1; end; if (f.AsInteger > 1000000) then begin SetLength(Result, len+1); Result[len] := len; len:= len+ 1; end; if (f.AsInteger > 10000000) then begin SetLength(Result, len+1); Result[len] := len; len:= len+ 1; end; end; //Draw array of images from ImageIndices array //ARect - Cell bounds procedure TForm1.DrawImages(ImageIndices: TIntegerDynArray; const ARect: TRect); var i: Integer; pos: TPoint; w: Integer; begin pos := ARect.Location; w := ImageList1.Width * Length(ImageIndices); pos.X := pos.X + (ARect.Width - w) div 2; for i := 0 to Length(ImageIndices) - 1 do begin ImageList1.Draw(DBGridEh1.Canvas, pos.X, pos.y, ImageIndices[i]); pos.X := pos.X + ImageList1.Width; end; end;
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |