我的DataGrid是要能编辑的只要我把那一行0,null,null,null删了,它就没有HasChanged了
真TMD奇怪,怎么会有一行0,null,null,null

解决方案 »

  1.   

    How do I prevent the datagrid from displaying its append row (the row at the end with an asterisk)?     The DataGrid class does not have a property that controls whether a new row can be added. But the DataView class does have such a property (along with some others such as AllowEdit and AllowDelete). Here is code that will turn off the append row by getting at the dataview associated with the datagrid. 
     
         string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb"; 
     
         string sqlString = "SELECT * FROM customers"; 
      
         // Connection object 
     
         OleDbConnection connection = new OleDbConnection(connString); 
      
         // Create data adapter object 
     
         OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection); 
      
         // Create a dataset object and fill with data using data adapter's Fill method 
     
         DataSet dataSet = new DataSet(); 
     
         dataAdapter.Fill(dataSet, "customers"); 
     
                    
     
         // Attach dataset's DefaultView to the datagrid control 
     
         dataGrid1.DataSource = dataSet.Tables["customers"]; 
      
         //no adding of new rows thru dataview... 
     
         CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];      
     
         ((DataView)cm.List).AllowNew = false;
     If your datagrid contains links, then Matthew Miller suggest adding Navigate handler such as the one below to disallow the AddNew. 
     
    private void DataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne) 
     

     
         if(ne.Forward) 
     
         { 
     
              CurrencyManager cm = (CurrencyManager)BindingContext[DataGrid1.DataSource,DataGrid1.DataMember]; 
     
              DataView dv = (DataView) cm.List; 
     
              dv.AllowNew = false; 
     
         } 
     
    }
     简单的英文要翻译吗?
      

  2.   

    问题是我这一行0,null,null下面才是那一行*号的
    各位老大帮我看看,有图
    http://www.ectoy.com/1.gif
      

  3.   

    把你的代码写出来看看
    可能是你在定义DataTable的时候新建了一行
      

  4.   

    我上传了代码
    http://www.ectoy.com/frmBooksList.cs
      

  5.   

    你的表设计的时候是不是有这样的性质:
    this.dataSet11.Tables[0].Columns[0].AutoIncrement=true;
      

  6.   

    nulltext是什么呢
    没有去设置this.dataSet11.Tables[0].Columns[0].AutoIncrement=true;
      

  7.   

    你看看DataSet中,取出来的值中又没有这样的一行!
      

  8.   

    datagrid和dataset中的datatable是完全一致的,不会出现你所说的情况,你填充dataset之前最好先new DataSet();一下。