1

I want to add row in my datagrid based on data that i fill in textbox. the display from page is just like this.

image 1

How can I possible to add row of datagrid based on data that i fill to textbox dynamically? Thanks

syaloom
  • 385
  • 5
  • 10
  • 21
  • http://stackoverflow.com/questions/21299016/how-to-refresh-or-show-immediately-in-datagridview-after-inserting try something like this. – sleath May 18 '15 at 04:06
  • Thanks xxmrlnxx, but the one I'm looking for is whenever i put data in my textbox, it's automatically adding into datagrid, without any button or else. is there any way to do that? – syaloom May 18 '15 at 04:12

1 Answers1

0

Try something like this. Using textchanged event. http://www.dotnetperls.com/textchanged

void textBox1_TextChanged(object sender, EventArgs e)
{
  PopulateGrid(textBox1.Text);
}
void PopulateGrid(string queryStr)
{
  dataGridView1.DataSource = _journal.GetSearchResults(queryStr);
  SetStatus(dataGridView1.Rows.Count); // Change status bar (not shown)
}

You can substitute the _journal.GetSearchResults(querystr) to just adding a datarow to a datatable then binding to the datasource. You should get the general concept.

sleath
  • 871
  • 1
  • 13
  • 42