Solved

delphi

Posted on 2013-06-10
5
338 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 25

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 25

Expert Comment

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now