cxgrid设置某列为其他列的乘积

procedure TfrmMedBack.cxSumColumn7GetDataText(Sender: TcxCustomGridTableItem;
  ARecordIndex: Integer; var AText: string);
begin
  if cxsum.DataController.RecordCount > 0 then
  begin
    if cxSum.DataController.GetValue(ARecordIndex,5) <> null then
    AText:=FloatToStrF( strtofloat(vartostr(cxSum.DataController.GetValue(ARecordIndex,2)))*
                       strtofloat(vartostr(cxSum.DataController.GetValue(ARecordIndex,5))),ffGeneral,10,2);
  end;
end;


------

procedure TfrmMedBack.cxSumEditing(Sender: TcxCustomGridTableView;
  AItem: TcxCustomGridTableItem; var AAllow: Boolean);
begin
  if aitem.index <> 5 then
    AAllow := false;
  if (AItem.GridView.ViewData.GetRecordByIndex(curindex).Values[5]
    > AItem.GridView.ViewData.GetRecordByIndex(curindex).Values[3]) then
  begin
    Messagebox(handle,'退药数量不能大于总数量?','提示信息',MB_OK +MB_ICONQUESTION);
    cxsum.Controller.FocusedRowIndex := curindex;
    cxSum.Controller.FocusedColumnIndex := 5;
    cxSum.Controller.FocusedColumn.FocusWithSelection;
  end;
end;


----获取单元格的值

cxsum.DataController.GetDisplayText(i,7)

你可能感兴趣的:(列,cxgrid)