Показать сообщение отдельно
  #9  
Старый 18.03.2010, 13:50
Мария Мария вне форума
Прохожий
 
Регистрация: 14.03.2010
Сообщения: 14
Репутация: 10
По умолчанию

Код:
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
    temp,temp1:string;
begin
  if(StringGrid1.ColCount mod 2 = 1) then
    temp1 := StringGrid1.Cells[StringGrid1.colcount-1,0];
  for i := 0 to stringgrid1.ColCount div 2 do begin
    temp := stringgrid1.Cells[2*i,0];
    StringGrid1.Cells[2*i,0]:= StringGrid1.Cells[2*i+1,0];
    StringGrid1.Cells[2*i+1,0] := temp;
  end;
   if(StringGrid1.ColCount mod 2 = 1) then
    StringGrid1.Cells[StringGrid1.colcount-1,0] := temp1;
end;

procedure TForm1.Button2Click(Sender: TObject);
  var i:integer;
begin
  randomize;
  for i:= 0 to StringGrid1.ColCount-1 do
    StringGrid1.Cells[i,0] := inttostr(random(128));
end;

end.
Admin: Напоминаю про теги!
Ответить с цитированием