开始DBEDIT的属性是可写的,我向里边写进去了数据,然后保存了数据。保存完数据以后,我想设置DBEDIT的属性为只读,不允许用户修改DBEDIT里边的数据。如果用普通方法dbedit.readonly:=true方法设置,因为有十几个DBEDIT,这个方法需要每个DBEDIT都设置一次,有没有简便一些的方法。我知道table.edit和table.insert是设置编辑和插入状态的,不知道有没有设置为只读状态的,也不知道这样的方法是否可行。如果大家有好的方法请大家告诉我,谢谢。

解决方案 »

  1.   

    全部选中所有这些控件
    设置readonly属性为true
      

  2.   

    楼上,如果用你的方法那么一开始就不能向DBEDIT里写入数据了,这可不行,我要先写入数据保存后在设置只读,请你重新看一下我题目是怎么说的。如果采用你的方法那我还不如用DBTEXT,该控件本来就是只读的
      

  3.   

    table1.CanModify:=false;
    这样就不允许修改数据库了哈哈哈哈《〈〈〉〉》
      

  4.   

    楼上,用你的方法报错是:Cannot assign to a read-only property,如何解决这个问题呢/?
      

  5.   


    if table1.state in [dsinsert] then
    begin
      for i:=0 to Controls.count-1 do
      begin
        if Controls[i] is TDbEdit then
           (Controls[i] as TDbEdit).readonly := false     
      end
    endif table1.state in [dsEdit] then
    begin
      for i:=0 to Controls.count-1 do
      begin
        if Controls[i] is TDbEdit then
           (Controls[i] as TDbEdit).readonly := true;
      end
    end
      

  6.   

    在datasource的onchange事件里写代码!
      

  7.   

    你保存完了之后
    table.edit.ReadOnly := True;
    可以的,没有问题
      

  8.   

    错了,应该是
    table.ReadOnly := True