0

I have a datagridview.

row 1, column 1, i want to get this cell value when i am typing.

i tried this.

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    int currentRow = dataGridView1.CurrentRow.Index;
    Console.WriteLine("cell value on live = " + dataGridView1.Rows[currentRow].Cells[0].Value.ToString());             
}

but i get this error

System.NullReferenceException: Object reference not set to an instance of an object. at inventory.Market.SalesOrder.dataGridView1_EditingControlShowing(Object sender, DataGridViewEditingControlShowingEventArgs e) in c:\Users\anto\Jual\Market\Penjualan.cs:line 123

stuartd
  • 62,136
  • 13
  • 120
  • 150
  • Why are you handling `EditingControlShowing` to do this? The [docs](https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridvieweditingcontrolshowingeventargs(v=vs.110).aspx) say _"Handle the EditingControlShowing event to perform custom initialization of the editing control when a cell enters edit mode"_. – stuartd Jan 05 '18 at 14:47
  • Plus, where does `currentRow` come from? What's its value when you debug the program? – stuartd Jan 05 '18 at 14:49
  • @stuartd see this question, i am trying to create a autocomplete https://stackoverflow.com/questions/48112025/c-sharp-datagridview-cell-with-autocomplete-like –  Jan 05 '18 at 14:52
  • @stuartd my bad, see my edit –  Jan 05 '18 at 14:53

0 Answers0