想控制DbgridEh中的同列某个单元格不能进行编辑,同列的其他单元格能够进行编辑,请问该怎样处理?

解决方案 »

  1.   

    在与dbgrideh关联的数据集的AfterScoll事件中进行判断,如果该行是允许编辑的则:
    dbgrideh.columns[dbgrideh.selectedIndex].readonly:=false;  否则
    dbgrideh.columns[dbgrideh.selectedIndex].readonly:=true;
      

  2.   

    你可以这样子做在 OnMouseDown事件中procedure TForm1.DBGridEh1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    const
      ACol = 1;//定义控制列
    begin
       with Sender as TDBGridEh do
         if (DataSource.DataSet.RecNo in [1, 3]) and (Col = ACol) then//该列的1,3单元格不可编辑
           ReadOnly := True else ReadOnly := False;
    end;