How do I update dataGridView when I click a button?

2
I'm using an interface where I have menustrip on the left and another form on the right, hence on menustrip has the options of novo (loads form nvCli ) and busca (loads form% ( nvConsCli ), it is necessary that when the user presses the busca option it will update the dataGridView of the form ( nvConsCli ) that will open, because if the user has just registered a record it already appears in gridView / p>

I tried with the following code:

nvConsCli.clientesTableAdapter.Fill(nvConsCli.regDataSet.clientes);

And another series of codes, but it does not work, it does not reload the database data and puts it in dataGridView

    
asked by anonymous 04.07.2015 / 06:05

2 answers

1

Create a method that only populates your dataGridView, so in the event of the fetch button, call this method at the end, so that whenever the fetch event is executed, the dataGridView will be updated with the data. If you can post the code I can respond with the appropriate changes.

    
30.07.2015 / 15:51
1

This ensures that every change in the DataSet is automatically applied to the DataGrid:

            ... // 1)Carregar seu DataSet 

            // 2) Criar um BindingSource
            BindingSource bs = new BindingSource(); 

            // 3 ) Relacionar o BS com seu DataSet
            bs.DataSource = idDoSeuDataSet; 

            //4) Relacionar o Grid com seu BindingSource 
            idDoSeuGridView.DataSource = bs; 

Update on the Click event

    
06.02.2016 / 10:55