Jump to content

How to draw (add) Row Number into Dbgrid as first column


irigsoft

Recommended Posts

Hello, in my desktop application I add First Column in every DBgrid and show Row ID, now I want to make this in DrawColumnCell, but I don't have TRect

here is my code on desktop, how to make this on uniGui ?:

if TDBGrid (Sender).DataSource.DataSet.RecNo > 0 then begin
  TRY
      If TDBGrid (Sender).Columns [0].Title.Caption <> '№' then begin
          TDBGrid (Sender).Columns.Insert (0);//TColumn.Create(SelDBGrid.Columns);
          TDBGrid (Sender).Columns [0].Title.Alignment := taCenter;
          TDBGrid (Sender).Columns [0].Title.Caption := '№';
          TDBGrid (Sender).Columns [0].Width := 24;
          TDBGrid (Sender).Columns [0].Alignment := taCenter;
          TDBGrid (Sender).Columns [0].Font.Color := clRed;
          TDBGrid (Sender).Columns [0].Font.Style := [fsBold];
      end;
      if Column.Title.Caption = '№' then begin
        TDBGrid (Sender).Canvas.TextOut(Rect.Left + 2, Rect.Top, IntToStr(TDBGrid (Sender).DataSource.DataSet.RecNo));
      end;
  EXCEPT

  END;
end;

Link to comment
Share on other sites

3 hours ago, Sherzod said:

Can you make a simple app to check? 

I am sorry. The project is complex, I don't have a way to separate Query from all functionality.

How to make with TAdoQuery select statement from Grid examples and Demo Databases?

example of my code:

SELECT ('<H2>'+ T1."Name" + '</H2>' 
        + '<ul><ul><h3 align="right">Price: '
        + CAST (ROUND (T1."Price",2) as varchar (20))
        + ', ' + lower (T1."Currency") + '</h3></ul></ul>' as ColName

FROM T1
);

From Image above: The first grid column is the RowID, the second is ActionColumn, the third is an image (Blob field), the fourth is the HTML data of 3 columns: name, price, currency

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...