0

I am unable to submit the value of a cell that is on focus when I hit a submit button that I have created. Is there a command to submit the value of a datagridview that has its cell on focus.

The value is only submitted when I hit enter and thus is when its focus is gone.

Valentine
  • 102
  • 1
  • 3
  • 12
  • Possible duplicate of [Why it doesn't save changes into datatable from datagridview?](http://stackoverflow.com/questions/17807373/why-it-doesnt-save-changes-into-datatable-from-datagridview) – TaW Feb 11 '16 at 10:35

1 Answers1

0

I am supposing you are trying to submit the Selected Value of a Cell into a TextBox, all you have to do is to trigger the textbox key down event and write..

private void textBox1_KeyDown(object sender, KeyEventArgs e)
  {
    if(e.KeyCode==Keys.Enter)
    {
      txtID.Text = dataGridView1.CurrentCell.Value.ToString();
      //do whatever you want to
    }
  }
Jamshaid K.
  • 3,555
  • 1
  • 27
  • 42