AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Stringgrid Zelle färben beim Editieren

Ein Thema von Bengalo · begonnen am 13. Okt 2008 · letzter Beitrag vom 17. Okt 2008
 
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.277 Beiträge
 
Delphi 10.4 Sydney
 
#6

Re: Stringgrid Zelle färben beim Editieren

  Alt 13. Okt 2008, 18:59
Hallo,

mal ein kleines Bsp.


Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids;

type
  TForm1 = class(TForm)
    Grid: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure GridDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  iCol : Integer;
  iRow : Integer;
begin
  for iCol:= 0 to Grid.ColCount-1 do
  begin
    for iRow:= 0 to Grid.RowCount-1 do
    begin
      Grid.Cells[iCol,iRow]:= IntToStr(iCol);
    end;
  end;
end;

procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if Grid.Cells[ACol,ARow]='0then
  begin
    Grid.Canvas.Brush.Color:= clRed;
    Grid.Canvas.FillRect(Rect);
  end
  else
  begin
    Grid.Canvas.Brush.Color:= clBlue;
    Grid.Canvas.FillRect(Rect);
  end;

  Inc(Rect.Left,2);
  DrawText(Grid.Canvas.Handle, PChar(Grid.Cells[ACol,ARow]),
    Length(Grid.Cells[ACol,ARow]), Rect,
    DT_END_ELLIPSIS or DT_NOPREFIX);
end;

Heiko
Heiko
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz