Показать сообщение отдельно
  #4  
Старый 22.05.2013, 07:53
Grynyuk Grynyuk вне форума
Прохожий
 
Регистрация: 21.05.2013
Сообщения: 25
Версия Delphi: Embarcadero RAD
Репутация: 10
По умолчанию

Спасибо помогло но теперь не могу установить курсор в ячейку стринггрид1 чтобы задать массив



Код:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;

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

var
  Form1: TForm1;
 const n=5;
implementation

{$R *.dfm}
Type Matrix=array [1..5,1..5] of real;
      vect= array[1..5]of integer;
Var   a:matrix;
s:real;
procedure TForm1.Button1Click(Sender: TObject);

var sm,smax,sd:string;
  j, i,ier,imax,jmax:integer;  max:real;
    begin
     for j:=1 to 5 do  begin
   for i:= 1 to 5 do if Length(Stringgrid1.Cells[i-1,0])<>0 then a[i,1]:= strtofloat(stringgrid1.Cells[i-1,0]) else a[i,j]:=0;
     end;
    for i:=1 to n do
begin
s:=0;
for j:=1 to n do
s:=s+strtofloat(StringGrid1.cells[j,i]);
strtofloat(stringgrid1.cells[n-j+1,j]);

stringgrid2.cells[i,1]:=floattostr(s);

      end;
    end;

procedure TForm1.Button2Click(Sender: TObject);

var j, i:integer;begin for i:=1 to n do
  for j:=1 to  n do
  stringgrid1.cells[j,i]:=' ' ;
    for j:=1 to  5 do
   stringgrid2.cells[j-1,1]:=' ';

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
   close;
end;


end.
Ответить с цитированием