OK!我已经解决了。原来是设置样式DataGridTableStyle里的问题,table的ReadOnly值不能在这写成true,否则它将一直是只读的,以后的修改无效。
private void TableStyleControl()
{
#region 设置样式
DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = "TBLPRODUCT";
tableStyle.RowHeadersVisible = true;
// tableStyle.ReadOnly = true;
tableStyle.AllowSorting = true;
tableStyle.BackColor = System.Drawing.Color.FromArgb(255,255,230);