6
I created an application that will display the data of a particular view in a control datagridview
.
The entire application is already ready: the data upload, the update button and also the events load
and activated
.
Technologies used:
- ADO.NET Entity Data Model
- EF 6.x Entityobject Generator
- SQL Server 2012
Note: I am using Bindingsource in the datagridview Datasource property to load the information.
Below is the code of my application:
private void frmDados_Load(object sender, EventArgs e)
{
CarregaDados();
}
private void CarregaDados()
{
using (var context = new DadosEntities())
{
vGRUPOSBindingSource.DataSource = context.VGRUPOS.ToList();
}
}
private void btnAtualizar_Click(object sender, EventArgs e)
{
CarregaDados();
}
/// <summary>
/// Evento acionado quando o foco retornar ao formulário
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmDados_Activated(object sender, EventArgs e)
{
CarregaDados();
}
My doubt
How to update control datagridview
automatically after any changes in table data?
Whether directed by the database or another open application being powered by other users.
The control needs to be updated without any user influence - by activating the focus on the application or by clicking the Update button.
Sample scenario
With my open application, defined as a information panel the information on the stock of products is displayed. As per another app a stock control (in Winform, Mobile or WEB), gives entrances or exits, my dashboard app needs to show new information.
It can happen also of a batch operation, update the stock of many products via database, ie a update
directly by SQL
, therefore, my information dashboard needs to update in real time the information on datagridview
.
Winform or WPF? Know Databinding?
– Renan Oliveira
I am using winform. Databinding already used in wpf.
– Ismael