每隔10秒钟刷新一次DBGRID,但每次刷新的时候DBGRID都会抖动,请高手指点。
谢了!

解决方案 »

  1.   

    DisableControls;
    EnableControls;这玩意是什么意思呀?
      

  2.   

    DisableControls;//更新数据集(TDataSet)时防止数据感知组件(DBGrid,DBEdit)跟着更新 也就是说不会产生抖现象了,如果不用,感知组件时时刷新,当然抖了
    EnableControls;//恢复原来状态,即感知组件随数据集时时更新
    这两句一定要用try finally 
    DisableControls
    DescriptionCall DisableControls prior to iterating through a large number of records in the dataset to prevent data-aware controls from updating every time the active record changes. Disabling controls prevents flicker and speeds performance because data does not need to be written to the display.If controls are not already disabled, DisableControls records the current state of the dataset, broadcasts the state change to all associated data-aware controls and detail datasets, and increments the dataset’s disabled count variable. Otherwise, DisableControls just increments the disabled count variable.The disabled count is used internally by other methods and objects to determine whether to display data in data-aware controls. When the disable count variable is greater than zero, data is not displayed.If the dataset is the master of a master/detail relationship, calling DisableControls also disables the master/detail relationship. Setting BlockReadSize instead of calling DisableControls updates the detail datasets as you scroll through the dataset, but does not update data-aware controls.Note: DisableControls can safely be called when controls are already disabled. In complex applications there may be separate operations that are sometimes nested, both of which need to disable controls.EnableControls;DescriptionCall EnableControls to permit data display in data-aware controls after a prior call to DisableControls. EnableControls decrements the disabled count variable for the dataset if it is not already zero. If the disable count variable is zero, EnableControls updates the current state of the dataset, if necessary, and then tells associated controls to re-enable display.
      

  3.   

    也就是说楼主在更新数据集时最好先用上这两句  TDataSet.DisableControls;
      try
       更新数据集;
     finally
      TDataSet.EnableControls;