
16.06.2011, 14:49
|
Прохожий
|
|
Регистрация: 15.06.2011
Сообщения: 9
Репутация: 10
|
|
С использованием компонента Stringgrid разработать приложение
С использованием компонента Stringgrid разработать приложение (по вариантам) в котором последний столбец (или строка) будет содержать рассчитанные значения.
Заголовки столбцов и строк – фиксированные.
Примерный вид интерфейса приведен на рисунке 1.
Расчет средней цены оборудования за 1 квартал. Результат уточнить до двух цифр после запятой. Данные в таблицу вводить с клавиатуры непосредственно в ячейки. Разрешить ввод только чисел от 1000 до 11500. Заголовки столбцов и строк – фиксированные.
Код:
procedure TForm1.FormCreate(Sender: TObject);
var i,j:integer;
begin
stringgrid1.RowCount:=7;
stringgrid1.ColCount:=7;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j:integer;
begin
for i:=0 to 7 do begin
for j:=0 to 7 do begin
StringGrid1.Cells[i,j]:='0';
if i=j then StringGrid1.Cells[i,j]:='1';
if i+j=6 then StringGrid1.Cells[i,j]:='1'else;
StringGrid1.Cells[i,0]:='1';
StringGrid1.Cells[i,6]:='1';
StringGrid1.Cells[3,j]:='1';
if (i+j=i+1) and (i>1)and (i<5) then StringGrid1.Cells[i,j]:='1';
if (i+j=i+5) and (i>1)and (i<5) then StringGrid1.Cells[i,j]:='1';
{if (j=0) and (i=6) then StringGrid1.Cells[i,j]:='1';
if (j=1) and (i=5) then StringGrid1.Cells[i,j]:='1';
if (j=2) and (i=4) then StringGrid1.Cells[i,j]:='1';
if (j=3) and (i=3) then StringGrid1.Cells[i,j]:='1';
if (j=4) and (i=2) then StringGrid1.Cells[i,j]:='1';
if (j=5) and (i=1) then StringGrid1.Cells[i,j]:='1';
if (j=6) and (i=0) then StringGrid1.Cells[i,j]:='1';}
end;
end;
{stringgrid1.Cells[j,i]:='1';
StringGrid1.Cells[0,1]:='0';
StringGrid1.Cells[0,2]:='0';
StringGrid1.Cells[0,3]:='0';
StringGrid1.Cells[0,4]:='0';
StringGrid1.Cells[0,5]:='0';
StringGrid1.Cells[1,2]:='0';
StringGrid1.Cells[1,3]:='0';
StringGrid1.Cells[1,4]:='0';
StringGrid1.Cells[2,3]:='0';
StringGrid1.Cells[6,1]:='0';
StringGrid1.Cells[6,2]:='0';
StringGrid1.Cells[6,3]:='0';
StringGrid1.Cells[6,4]:='0';
StringGrid1.Cells[6,5]:='0';
StringGrid1.Cells[5,2]:='0';
StringGrid1.Cells[5,3]:='0';
StringGrid1.Cells[5,4]:='0';
StringGrid1.Cells[4,3]:='0'; }
end;
end.
|