Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.11.13;
Скачать: CL | DM;

Вниз

Tms Adv Grid - как сделать суммрование и...?   Найти похожие ветки 

 
jiurasdfsdfs   (2005-10-21 19:55) [0]

Доброе время суток: может кто подскажет как в TMS Grid-е сделать чтобы сумма 2,3,4 столбца отображалась в 5-ом?
И кака сделать чтобы во 2,3,4 можнобыло вводить только цифры?
М вообще где можно скачать Help по TMS?


 
irishka001 ©   (2005-10-22 00:03) [1]

Для получения суммы:

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;


 
isasa ©   (2005-10-22 09:47) [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;


 
isasa ©   (2005-10-22 09:50) [3]

Не проснулся.
События:

OnCellValidate
OnCanEditCell

соответственно



Страницы: 1 вся ветка

Текущий архив: 2005.11.13;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.024 c
1-1129714837
Mamed
2005-10-19 13:40
2005.11.13
Perevod so Ci na paskal


4-1125846248
Sormy
2005-09-04 19:04
2005.11.13
RSA decrypting


2-1130240207
VEZ
2005-10-25 15:36
2005.11.13
Hex SpinEdit


14-1130140271
syte_ser78
2005-10-24 11:51
2005.11.13
какие базы (локальные) поодерживают украинскую локализацию?


4-1126241076
Фагот
2005-09-09 08:44
2005.11.13
Перехват клавиш в консольном приложении