起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 256|回复: 2

【结】[]关于在表格文档中如何动态的控制字段的只读属性

[复制链接]
发表于 2010-7-6 09:36:19 | 显示全部楼层 |阅读模式
在业务功能运行(表格文档)的过程中,当某一个字段发生变化时如何用代码实现,其它一些字段的只读属性?
回复

使用道具 举报

 楼主| 发表于 2010-7-6 09:40:01 | 显示全部楼层
procedure TMainForm.DataSetBroker2DataChange(Sender: TObject; Field: TDataField);
begin
   if (Field <> nil) and (field.FieldName = 'GZLX') THEN
   begin

      if datasetbroker2.DataSet.FieldByName('GZLX').AsString = '岗薪工资' then
      begin

         datasetbroker2.DataSet.FieldByName('GJ').ReadOnly := True;
         datasetbroker2.DataSet.FieldByName('XJ').ReadOnly := True;
         datasetbroker2.DataSet.FieldByName('GX').ReadOnly := True;
         datasetbroker2.DataSet.FieldByName('BGXJ').ReadOnly := True;
      end;
      if datasetbroker2.DataSet.FieldByName('GZLX').AsString = '大学生工资' then
      begin
         datasetbroker2.DataSet.FieldByName('JX').ReadOnly := True;
         datasetbroker2.DataSet.FieldByName('FX').ReadOnly := True;
      end;
      if datasetbroker2.DataSet.FieldByName('GZLX').AsString = '外聘工资' then
      begin
         datasetbroker2.DataSet.FieldByName('YGZ').ReadOnly := True;
         datasetbroker2.DataSet.FieldByName('JBT').ReadOnly := True;
      end;
   end;
end;



上面的代码没起作用,字段还是只读的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-7-6 09:44:05 | 显示全部楼层
是我把true和false 搞反了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-8 03:33 , Processed in 0.042287 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表