Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

StringGrid: Bold Titles

Posted on 2003-03-31
6
Medium Priority
?
2,978 Views
Last Modified: 2007-12-19
One of two quick questions. Is it possible to have the title row (Row 0) of a stringgrid bolded while the body of the grid is not?
0
Comment
Question by:MartinC
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 8243101
Hi MartinC,
use onDrawCell event to draw cell with your style.
Search in this TA by keyword onDrawCell to get samples.
____
Igor
0
 

Author Comment

by:MartinC
ID: 8243177
ITugay:

I tried that but it doesn't seem to work. I used the following code:

procedure TFrmMain.sgStudentDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if ARow = 0 then
  begin
    color := clBtnface;
    font.style := [fsBold];
  end;
end;

... but it produced no change to the top row. I have FixedRows set to 1 as well and FixedColor set to clBtnFace but it doesn't differentiate the top line from the others at all.

When you said "Search in this TA by keyword onDrawCell to get samples" did you just mean the Help? I don't know what "this TA" is.
0
 
LVL 9

Accepted Solution

by:
ITugay earned 63 total points
ID: 8243204
Hi MartinC,
should be something like this

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if ARow = 0 then
    with StringGrid1, Canvas do
    begin
      Font.Style := [fsBold];
      TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
    end;
end;

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:ITugay
ID: 8243211
TA - topic area,
I mean Delphi topic area in experts-exchange

____
Igor
0
 
LVL 1

Expert Comment

by:nafeelm
ID: 8243964
try this:


procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState);
var CellStr: String;
begin
  if Row = 0 then
  begin
    CellStr:=StringGrid1.Cells[Col, Row];
    StringGrid1.Canvas.Font.Style:=[fsBold];
    ExtTextOut(StringGrid1.Canvas.Handle,Rect.Left+2,Rect.Top+2,ETO_CLIPPED or ETO_OPAQUE, @Rect, PChar(CellStr), Length(CellStr),nil);
  end;
end;

0
 

Author Comment

by:MartinC
ID: 8259489
Hmm, doesn't look like I am going to get what I am looking for. I was hoping for a simple on/off solution for the Fixed Rows.

OnDrawCell is no good because having the thing called every single time a cell is drawn makes the game probably not worth the candle.

ITugay's answer is best of the OnDrawCell solutions, so I will award the points there.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

569 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