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)














本文转自鹅倌51CTO博客,原文链接: http://blog.51cto.com/kaixinbuliao/1582522,如需转载请自行联系原作者




上一篇:C# dataGridView右键菜单


下一篇:以C语言为例的程序性能优化 --《深入理解计算机系统》第五章读书笔记