Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

delphi

Posted on 2013-06-10
5
Medium Priority
?
347 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
[X]
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
  • 3
5 Comments
 
LVL 27

Accepted Solution

by:
Sinisa Vuk earned 1500 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 27

Expert Comment

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

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

688 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