How to run cellendedit when a cell value changes in the data

Jul 28 2017 3:39 AM
The CellEndEdit event is running when I edit the datagridview cells, but when I print the data from the database to the DataGridView cell, CellEndEdit does not work:
 
 
  1. dataGridView1.Rows[0].Cells[0].Value = "test";  
 

How can I run CellEndEdit?

My code:

 
 
  1. private void btnKaydet_Click(object sender, EventArgs e)  
  2.         {  
  3.             try  
  4.             {  
  5.                 int index = 2;  
  6.                 int rc = gridView1.RowCount;  
  7.                 for (int i = 0; i < rc; i++)  
  8.                 {  
  9.                     index++;  
  10.                     string stk = gridView1.GetRowCellValue(i, "STOKKODU").ToString();  
  11.                     string beden = gridView1.GetRowCellValue(i, "BEDEN").ToString();  
  12.                     string mik = gridView1.GetRowCellValue(i, "MIKTARI_2").ToString();  
  13.                     dataGridView1.Rows[index].Cells[0].Value = stk;  
  14.                     dataGridView1.Rows[index].Cells[1].Value = beden;  
  15.                     dataGridView1.Rows[index].Cells[2].Value = mik;  
  16.                 }  
  17.                 ExcelProje.Save();  
  18.             }  
  19.             catch (Exception ex)  
  20.             {  
  21.                 MessageBox.Show(ex.Message);  
  22.             }  
  23.         }  
  24.    
  25.   
  26.    
  27. private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)  
  28.         {  
  29.             object hucre = ExcelSayfa.Cells[dataGridView1.CurrentCell.RowIndex + 2, dataGridView1.CurrentCell.ColumnIndex + 1];  
  30.             Excel.Range bolge = ExcelSayfa.get_Range(hucre, hucre);  
  31.             bolge.Value2 = dataGridView1.CurrentCell.Value;  
  32.         }