?
Solved

StringGrid: Bold Titles

Posted on 2003-03-31
6
Medium Priority
?
2,748 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: 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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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