![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Tms Adv Grid - как сделать суммрование и...?
jiurasdfsdfs © (2005-10-21 19:55:00)Доброе время суток: может кто подскажет как в TMS Grid-е сделать чтобы сумма 2,3,4 столбца отображалась в 5-ом?
И кака сделать чтобы во 2,3,4 можнобыло вводить только цифры?
М вообще где можно скачать Help по TMS?
isasa (2005-10-22 09:50:00) [1]Не проснулся.
События:
OnCellValidate
OnCanEditCell
соответственно
isasa (2005-10-22 09:47:00) [2]Обрати внимание на следующие события компонента.
1. Заполняем запись Data в зависимости от положения в строке и колонке, после редактирования Cell
procedure TChildFlow.ConditionGridCellValidate(Sender: TObject; ACol,
ARow: Integer; var Value: String; var Valid: Boolean);
var x : double;
list : TStringList;
begin
case ACol of
1,2:
try
x:=dVal(Value);
case ARow of
1: Data.Pi[ACol-1]:=x;
2: Data.Pb[ACol-1]:=x;
3: Data.T[ACol-1]:=x;
4: Data.Rn[ACol-1]:=x;
5: Data.Xa[ACol-1]:=x;
6: Data.Xc[ACol-1]:=x;
end;
Value:=format('%g', [x]);
except
end;
3: begin
list:=TAdvColumnGrid(sender).Columns[2].ComboItems;
if ARow=1 then Data.ePi:=list.IndexOf(Value)
else Data.ePb:=list.IndexOf(Value);
end;
end;
end;
2. Проверка доступности ячеек дя редактирования по значению индекса в TypeSGroup
procedure TChildFlow.ConditionGridCanEditCell(Sender: TObject; ARow,
ACol: Integer; var CanEdit: Boolean);
begin
case ARow of
4,5,6: CanEdit:=(TypeSGroup.ItemIndex=3);
7,8: CanEdit:=(TypeSGroup.ItemIndex in [6,7]);
9: CanEdit:=(TypeSGroup.ItemIndex in [7]);
end;
end;
irishka001 (2005-10-22 00:03:00) [3]Для получения суммы:
var
a: char;
i,n:integer;
str:string;
begin
//заполняем SGrid
SGrid.cells[1,0]:=inttostr(12);
SGrid.cells[1,1]:=inttostr(13);
SGrid.cells[1,2]:=inttostr(15);
SGrid.cells[2,0]:=inttostr(76);
SGrid.cells[2,1]:=inttostr(55);
SGrid.cells[2,2]:=inttostr(5);
SGrid.cells[3,0]:=inttostr(1);
SGrid.cells[3,1]:=inttostr(23);
SGrid.cells[3,2]:=inttostr(70);
for i:= 0 to Sgrid.RowCount do //цикл по строкам
begin
SGrid.Cells[4,i]:='0';
for n:=1 to 3 do // цикл по столбцам
if SGrid.Cells[n,i]<>'' Then
SGrid.Cells[4,i]:=IntToStr(strtoint(SGrid.Cells[4,i])+strtoint(SGrid.Cells[n,i]))
else
SGrid.Cells[4,i]:=''
end;
end;
А для ограничения ввода только числовыми значениями можно попробовать:
str:=Edit1.Text;
for i:=1 to length(Edit1.Text) do
begin
if (ord(Edit1.Text[i])<48) or (ord(Edit1.Text[i])>57) then
begin
Messagedlg('Попытка ввести нечисловое значение', mtInformation, [mbAbort], 0);
exit;
end
else
SGrid.cells[0,1]:=edit1.Text;
end;