Показать сообщение отдельно
  #4  
Старый 09.05.2013, 12:25
Аватар для Alegun
Alegun Alegun вне форума
LMD-DML
 
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
По умолчанию

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
  Dialogs, StdCtrls, Grids, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    DateTimePicker1: TDateTimePicker;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Col  : integer = 1;
  Row  : integer = 1;

  implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
// Очистка содержимого всех ячеек таблицы
 for i := StringGrid1.FixedRows to StringGrid1.RowCount - 1
       do StringGrid1.Rows[i].Clear;

 // Добавление данных в нужную ячейку
 StringGrid1.Cells[Col, Row]:= DateToStr(DateTimePicker1.Date);
 inc(Col);
 if Col = StringGrid1.ColCount then
 begin
  Col:= 1;
  inc(Row);
  if Row = StringGrid1.RowCount then Row:= 1;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;

end.
Вся сборка тут
Ответить с цитированием