首页 > 代码库 > cxgrid设置某列为其他列的乘积

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;

本文出自 “一切有为法,如梦幻泡影” 博客,请务必保留此出处http://kaixinbuliao.blog.51cto.com/2567365/1582522

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