how to add textbox value to gridview in c#
  • how to fill textbox value in datagridview i have textbox and datagridview i want to fill textbox value to to gridview cell.
  • 1 Comment sorted by
  • Vote Up0Vote Down WaqasWaqas
    172.00 Karma Accepted Answer
    hi use this code.


    private void button1_Click(object sender, EventArgs e)
    {
    int RowIndex = 0;
    dataGridView1.Rows.Add();

    RowIndex = dataGridView1.Rows.Count - 2;

    // insert values from textboxe to DataGridView
    dataGridView1[0, RowIndex].Value = textBox1.Text;
    dataGridView1[1, RowIndex].Value = textBox2.Text;
    dataGridView1.Refresh();


    // Clear textboxes and focus for new entry
    textBox1.Text = "";
    textBox2.Text = "";

    textBox1.Focus();
    }


Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

    Optimum Creative