procedure TForm1.DBGrid1ColumnMoved(Sender: TObject; FromIndex, ToIndex: Integer); begin if FromIndex = 0 then//这里可根据你得情况设置,这里是不运行拖动第一列 begin DBGrid1.Columns[ToIndex].Index := FromIndex; end; end;
通过下列代码实现了: procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin if Dbgrid1.SelectedField.FieldName='序号' then if Dbgrid1.SelectedIndex < Dbgrid1.FieldCount-1 then Dbgrid1.SelectedIndex:=Dbgrid1.SelectedIndex+1 else Dbgrid1.SelectedIndex:=0; end;