Главная страница
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.046 c
5-1109742825
Аюс
2005-03-02 08:53
2005.11.13
FreeNotification(Self) принцип работы ?


2-1129657702
Galiaf
2005-10-18 21:48
2005.11.13
Динамический двухмерный массив.


1-1130146907
MBoris
2005-10-24 13:41
2005.11.13
Как в одну ячейку StringGrid засунуть две строки?


14-1129843959
beglec
2005-10-21 01:32
2005.11.13
Как работать с почтой


9-1120113497
_Max
2005-06-30 10:38
2005.11.13
хранение данных