this slowpoke moves

Draw Matrix Raster in StringGrid

uses ExtCtrls, Grids

//

procedure DrawMatrix(Grid: TStringGrid; ACol, ARow, M, N: Integer; LineColor: TColor;
   LineWidth: Integer; State: TGridDrawState; Sender: TObject; Rect: TRect);
begin
  //Horizontale Linien ohne Fixed Spalten
  if ((ARow-Grid.FixedRows+1) MOD M = 0) AND NOT (gdFixed In State) Then
  begin
    with (sender as TStringGrid).Canvas do
    begin
      Pen.Color := LineColor;
      Pen.Width := LineWidth;
      Pen.Style := psSolid;
      MoveTo(Rect.Left-1,Rect.Bottom);
      LineTo(Rect.Right-1,Rect.Bottom);
    end;
  end;
  //Vertikale Linien ohne Fixed Zeilen
  if ((ACol-Grid.FixedCols+1) MOD N = 0) AND NOT (gdFixed In State) Then
  begin
    with (sender as TStringGrid).Canvas do
    begin
      Pen.Color := LineColor;
      Pen.Width := LineWidth;
      Pen.Style := psSolid;
      MoveTo(Rect.Right,Rect.Top-1);
      LineTo(Rect.Right,Rect.Bottom-1);
    end;
  end;
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var Grid: TStringGrid;
begin
  //5X5 Matrix zeichnen
  DrawMatrix(Grid, ACol, ARow, 5, 5, clBlack, 2, State, Sender, Rect);
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate