Board index » delphi » Cells in TStringGrid and descendants....

Cells in TStringGrid and descendants....

Does anyone know where I can get hold of a descendant of TStringGrid that gives me more control over
cells. I have an app where I need to set font and color settings for just about any cell on a grid
and I'm currently forced to make up a grid out of individual TEdit or TDBEdit fields.

Thanx in advance....

Paul

 

Re:Cells in TStringGrid and descendants....


In this example I paint a odd cells in second column with bold font and
right alignment:

procedure TfrmDSImport.sgFieldsMapDrawCell(Sender: TObject; Col,
  Row: Integer; Rect: TRect; State: TGridDrawState);
const
  AlignFlags: array [TAlignment] of Integer =
     (DT_LEFT or DT_VCENTER or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX,
      DT_RIGHT or DT_VCENTER or DT_WORDBREAK or DT_EXPANDTABS or
DT_NOPREFIX,
      DT_CENTER or DT_VCENTER or DT_WORDBREAK or DT_EXPANDTABS or
DT_NOPREFIX);
var s: string;
begin
  inherited;

  with Rect do
  begin
    Left := Left + 2;
    Top := Top + 2;
    Right := Right - 5
  end;

  s := sgFieldsMap.Cells[Col, Row];

  if (Col = 1) and (Row > 0) and (Row < sgFieldsMap.RowCount) and (Row mod 2
= 1) then
  begin
    sgFieldsMap.Canvas.Font.Style := sgFieldsMap.Canvas.Font.Style +
[fsBold];
    sgFieldsMap.Canvas.Brush.Color := sgFieldsMap.FixedColor;
    sgFieldsMap.Canvas.FillRect(Rect);

    DrawText(sgFieldsMap.Canvas.Handle,
             PChar(s), Length(s),
             Rect, AlignFlags[taRightJustify]);
  end
end;

--
With best regards, Mike Shkolnik.
FIDO: 2:463/106.14
E-Mail: mshkol...@rs-ukraine.kiev.ua
        m...@woccu.freenet.kiev.ua
WEB: http://www.geocities.com/SiliconValley/Grid/3989

Paul Mason D??? ???Y?? <7f6v27$k...@forums.borland.com> ...

Quote
>Does anyone know where I can get hold of a descendant of TStringGrid that

gives me more control over
Quote
>cells. I have an app where I need to set font and color settings for just

about any cell on a grid
Quote
>and I'm currently forced to make up a grid out of individual TEdit or
TDBEdit fields.

>Thanx in advance....

>Paul

Re:Cells in TStringGrid and descendants....


I have a couple TStringGrid tips that include what you are looking for.  I
set the color and font in the TStringGrid.OnDrawCell event.
http://members.truepath.com/delphi
--
--
Lewis Howell
lewishwo...@yahoo.com
Lou's Delphi Tip of the Day:
http://members.truepath.com/delphi
Lou's personal webpage:
http://members.truepath.com/LewisHowell

Quote
Paul Mason wrote in message <7f6v27$k...@forums.borland.com>...
>Does anyone know where I can get hold of a descendant of TStringGrid that

gives me more control over
Quote
>cells. I have an app where I need to set font and color settings for just

about any cell on a grid
Quote
>and I'm currently forced to make up a grid out of individual TEdit or
TDBEdit fields.

>Thanx in advance....

>Paul

Re:Cells in TStringGrid and descendants....


Hi Paul,

We have a string grid that provides all the properties for fonts, select
color, text aligniment, bitmaps, disabled fonts, disabled color etc. for
each cell. All properties can be edited at design time and visually with
our powerful property editor.  In addition we also have properties for
controling the properties for a column and row.  Check us out:
http://www.res-cue.com
--
Earl Reddell
Res-cue (Resourceful Components for User Ease!)
Check out our web site: http://www.res-cue.com

Quote
> Does anyone know where I can get hold of a descendant of TStringGrid that

gives me more control over

Re:Cells in TStringGrid and descendants....


Quote
Paul Mason wrote in message <7f6v27$k...@forums.borland.com>...
>Does anyone know where I can get hold of a descendant of TStringGrid that

gives me more control over
Quote
>cells. I have an app where I need to set font and color settings for just

about any cell on a grid
Quote
>and I'm currently forced to make up a grid out of individual TEdit or

TDBEdit fields.

There are lots of extended stringgrid components available on the web,
freeware, shareware, and commercial. But before doing that you should take a
look at some samples that shows some of what you can do with the standard
stringgrid just by using the OnDrawCell event - you may not need anything
else. My sample doesn't show painting graphics but this can be done in
exactly the same place.

You can download a free sample to demonstrate this from my site:
http://home.ican.net/~wniddery/freedelphistuff.html

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
"You know you've landed gear-up when it takes full power to taxi"

Other Threads