Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.042 c
1-1130228385
Vriter
2005-10-25 12:19
2005.11.13
Расширение CheckListBox


2-1129983763
Ромио
2005-10-22 16:22
2005.11.13
Office


3-1127385873
Anat
2005-09-22 14:44
2005.11.13
ORACLE DBMS_PIPE need HELP


4-1126375396
Mister Twister
2005-09-10 22:03
2005.11.13
Опасен ли CM_RECREATEWND?


4-1126089449
Хинт
2005-09-07 14:37
2005.11.13
Проблема с ReadProcessMemory




   Наверх