Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

delphi

Posted on 2013-06-10
5
342 Views
Last Modified: 2013-06-26
in tdrawgrid i need to change the font  of one specific row, based on the value of one field.

When i am trying this with onDrawcell event, as below:

Sender.Canvas.Font.Style := [fsBold], font of whole grid is changing.

Any idea?
0
Comment
Question by:AbhiJeet
  • 3
5 Comments
 
LVL 26

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 39234789
You should check if specific cell row/column is drawing:

...
   Sender.Canvas.Font.Style := [];
   if (ARow = 3) and ... then //check if it is valid row 
   begin
      Sender.Canvas.Font.Style := [fsBold];
   end;
...

Open in new window

0
 

Author Comment

by:AbhiJeet
ID: 39235463
all rows from 3rd row are getting bold by this method.
0
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39236241
can you paste your code here? at least simplified. Did you set DefaultDrawing to false?
0
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39236998
Made simple example:
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  s: String;
begin
  TDrawGrid(Sender).Canvas.Brush.Color := TDrawGrid(Sender).Color;
  TDrawGrid(Sender).Canvas.Brush.Style := bsSolid;
  TDrawGrid(Sender).Canvas.FillRect(Rect);

  TDrawGrid(Sender).Canvas.Font.Style := [];
  if (ARow = 3) then //check if it is valid row
  begin
    TDrawGrid(Sender).Canvas.Font.Style := [fsBold];
  end;

  s := 'fdfdgfdgfd';
  TDrawGrid(Sender).Canvas.TextOut(
    Rect.Right - TDrawGrid(Sender).Canvas.TextWidth(s) - 2,
    Rect.Top + 8 - (TDrawGrid(Sender).Canvas.TextHeight(s) div 2),
    s
    );
end;

Open in new window

0
 
LVL 6

Expert Comment

by:House_of_Dexter
ID: 39248849
change this to

  if (ARow = 3) then //check if it is valid row
  begin
    TDrawGrid(Sender).Canvas.Font.Style := [fsBold]
  end else
    TDrawGrid(Sender).Canvas.Font.Style := [];

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 65
control image tags in a string ? 12 141
How to load 2 images in same column in Delphi 2 57
how to change, disabled button color FMX ? 1 40
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question