I have a DataGridView and few TextBox and combo box controls. when i enter data in textbox controls and click on add button the values are added to
Add row in your Datasource and then set the datasource to updated datatable. Like:
private void BtnAdd_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" | textBox3.Text == "" | textBox4.Text == "" comboBox1.SelectedIndex == 0 | textBox5.Text == "" | textBox6.Text == "" | textBox7.Text == "" | textBox8.Text == "" | textBox9.Text == "" | textBox10.Text == "" | textBox11.Text == "" | textBox12.Text == "")
{
MessageBox.Show("Values Should not Be empty!");
textBox3.Focus();
}
else
{
DataTable dt = dataGridView1.DataSource as DataTable;
dt.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, richTextBox1.Text, comboBox1.Text, textBox5.Text, comboBox2.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text, textBox10.Text, textBox11.Text, textBox12.Text);
dataGridView1.DataSource = dt;
}
}