Добавил:
Источник:
Uman
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:02 семестр / Задачи на Paskal / Stringgrid. Примеры задач / Шаблон / Unit1
.pas unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, Grids;
type
TForm1 = class(TForm)
stringgrid1:tstringgrid;
ListBox1: TListBox;
Button4: TButton;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin
stringgrid1.Options:=stringgrid1.options+[goediting];
stringgrid1.colcount:=5;
stringgrid1.RowCount:=50;
stringgrid1.fixedrows:=1;
stringgrid1.fixedcols:=0;
stringgrid1.Cells[0,0]:='Name';
stringgrid1.Cells[1,0]:='Group';
stringgrid1.Cells[2,0]:='Mark1';
stringgrid1.Cells[3,0]:='Mark2';
stringgrid1.Cells[4,0]:='Mark3';
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j,s:integer;
begin
for i :=1 to stringgrid1.rowcount-1 do
if stringgrid1.cells[0,i]<>'' then
begin
s:=0;
for j:=2 to 4 do
s:=s+strtoint(stringgrid1.Cells[j,i]);
if s=15 then
listbox1.Items.add(stringgrid1.cells[0,i]+' '+stringgrid1.cells[1,i]);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i,j,n,m:integer;
begin
n:=stringgrid1.colcount;
m:=stringgrid1.rowcount;
for j:=0 to n-1 do
for i:=1 to m-1 do
stringgrid1.cells[j,i]:='';
listbox1.Items.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, Grids;
type
TForm1 = class(TForm)
stringgrid1:tstringgrid;
ListBox1: TListBox;
Button4: TButton;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin
stringgrid1.Options:=stringgrid1.options+[goediting];
stringgrid1.colcount:=5;
stringgrid1.RowCount:=50;
stringgrid1.fixedrows:=1;
stringgrid1.fixedcols:=0;
stringgrid1.Cells[0,0]:='Name';
stringgrid1.Cells[1,0]:='Group';
stringgrid1.Cells[2,0]:='Mark1';
stringgrid1.Cells[3,0]:='Mark2';
stringgrid1.Cells[4,0]:='Mark3';
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j,s:integer;
begin
for i :=1 to stringgrid1.rowcount-1 do
if stringgrid1.cells[0,i]<>'' then
begin
s:=0;
for j:=2 to 4 do
s:=s+strtoint(stringgrid1.Cells[j,i]);
if s=15 then
listbox1.Items.add(stringgrid1.cells[0,i]+' '+stringgrid1.cells[1,i]);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i,j,n,m:integer;
begin
n:=stringgrid1.colcount;
m:=stringgrid1.rowcount;
for j:=0 to n-1 do
for i:=1 to m-1 do
stringgrid1.cells[j,i]:='';
listbox1.Items.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
end.