Henry Olive 5 Posted December 15 Good Day My DBGrid has JUST 2 rows (cant be more) Group Jan Feb..... ------------------- A 10 20 B 12 16 How can i make JUST second row's Fonts to Bold like below ? Group Jan Feb..... ------------------- A 10 20 B 12 16 Thank You Share this post Link to post
PeterBelow 239 Posted December 15 Look at this help entry for an overview of how to modify the way a TDBGrid is drawn. In your case set the DefaultDrawing property of the grid to false and attach a handler to the OnDrawColumnCell event. The handler can check the attached dataset's current row to see what row it has to draw. If it is the first just call the grid's DefaultDrawColumnCell method directly. If it is the second row change the grid.canvas.font to bold first and then call DefaultDrawColumnCell. That should do what you want. Share this post Link to post
Henry Olive 5 Posted December 15 Thank you Peter My code : procedure TManTargets.DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if CDS2.Eof then begin DBGrid2.Font.Style:=[fsBold]; DbGrid2.Canvas.FillRect(rect); DBGrid2.DefaultDrawColumnCell(Rect, DataCol, Column, State); end; end; I dont get error msg. but the code doesnt make Bold the last row of the dbgrid Share this post Link to post
Lajos Juhász 295 Posted December 15 At the second row is not the end of the dataset, eof is going to be true when you call next on the last row. You can check recno or a value of the group field. Share this post Link to post
Softacom | Company 2 Posted 27 minutes ago Here procedure TForm3.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin //detect last row of DataSet if DBGrid1.DataSource.DataSet.RecNo = DBGrid1.DataSource.DataSet.RecordCount then DBGrid1.Canvas.Font.Style := [fsBold]; //draw cell DBGrid1.DefaultDrawDataCell(Rect, Field, State); end; Don't forget to set property DefaultDrawing into False to prevent draw data few times Share this post Link to post