Recent

Author Topic: virtualdbtreeex image on columns  (Read 730 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
virtualdbtreeex image on columns
« on: November 01, 2022, 10:24:40 pm »
I  Playing with virtualdbtreeext  I trying  to show image at column you know some time we wanna to show image reference to value to cell,

This is my conde don't send me eny error but don't show image i don't know if i missing something...


procedure TFormAssyParts.VirtualDBTreeEx1BeforeCellPaint(
  Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect;
  var ContentRect: TRect);
begin
  with VirtualDbTreeEx1.Canvas do  begin
      if( column = 5  ) then begin
         VirtualDbTreeEx1.Canvas.FillRect(CellRect);
          if( VirtualDbTreeEx1.DataSource.DataSet.FieldByName('RxPLType').AsString ='DWG') then begin
             imagelPart.Draw(VirtualDbTreeEx1.Canvas , CellRect.CenterPoint.x-8,ClipRect.CenterPoint.Y-8,3 );
 //            TextOut(CellRect.Left+3, CellRect.top+1 , 'DWG');
          end else begin
            TextOut(CellRect.Left+3, CellRect.top+1 , 'Afected');
          end;
      end;
  end;
end;   

I don't sure if must be here or different event...

dseligo

  • Hero Member
  • *****
  • Posts: 1222
Re: virtualdbtreeex image on columns
« Reply #1 on: November 01, 2022, 11:02:28 pm »
This is my conde don't send me eny error but don't show image i don't know if i missing something...

Maybe you have it in a wrong color?

balazsszekely

  • Guest
Re: virtualdbtreeex image on columns
« Reply #2 on: November 02, 2022, 06:57:53 am »
@eldonfsr
Quote
I  Playing with virtualdbtreeext  I trying  to show image at column you know some time we wanna to show image reference to value to cell,

This is my conde don't send me eny error but don't show image i don't know if i missing something...

I don't sure if must be here or different event...
Definitely not on BeforeCellPaint. Move your code to AfterCellPaint. Instead of TextOut use the DrawText function from LCLIntf. Also you have to calculate the exact position of the text, with or without the image. Please do a forum search, there are several threads out there with similar requirements.

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: virtualdbtreeex image on columns
« Reply #3 on: November 02, 2022, 08:59:06 pm »
Thanks for your guide , I Made a change to event afterpaint but CellRect  don't take position in dbgrid the values got is dbgrid ans also show or the event is trigger when click on Register , I need when loading data put a image on column, and events you taold is triger on node of tree...

Code: Pascal  [Select][+][-]
  1. procedure TFormAssyParts.VirtualDBTreeEx1AfterCellPaint(
  2.   Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  3.   Column: TColumnIndex; const CellRect: TRect);
  4. Var aRect:TRect;
  5. begin
  6.    with VirtualDbTreeEx1.Canvas do  begin
  7.        ARect:= CellRect;
  8.       if( column = 5  ) then begin
  9.          VirtualDbTreeEx1.Canvas.FillRect(CellRect);
  10.           if( VirtualDbTreeEx1.DataSource.DataSet.FieldByName('RxPLType').AsString ='DWG') then begin
  11.              imagelPart.Draw(VirtualDbTreeEx1.Canvas , aRect.CenterPoint.x   ,aRect.CenterPoint.Y+8,3 );
  12.              DrawText( VirtualDbTreeEx1.Canvas.Handle ,Pchar(VirtualDbTreeEx1.DataSource.DataSet.FieldByName('RxPLType').AsString) , -1, aRect , DT_CENTER );
  13.           end;
  14.       end;
  15.   end;
  16. end;  
  17.  


You can see show image at top of the grid...

eldonfsr

  • Sr. Member
  • ****
  • Posts: 447
Re: virtualdbtreeex image on columns
« Reply #4 on: December 10, 2022, 08:44:01 pm »
DBTree cellafterpaint is triger only when click on node not when is showing the form or dbtree i need event witch triger when load like drawcell of dbgrid... to attach image to column.

 

TinyPortal © 2005-2018