void TextBox1KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char) 13)
{
{
string dates = textBox1.Text.ToString(); // assign the Textbox value to a string
int i = dataGridView1.Rows.Count; // count the Number of available rows in the GridView
int j = i - 1; //counted the Rows minus 1 that will make you add Rows
this.dataGridView1.Rows.Add(); // create the Rows if it is needed
dataGridView1.Rows[j].Cells[0].Value = dates; // add the Values to the GridView
textBox1.Text = ""; //Empty the Textbox
}
}This code is allow us to add the values in Datagrid view by pressing ENTER Key.
