My DataGridView
displays information that is entered on another system. As the user insert, update or delete any information, the DataGridView
should be updated right now.
I thought about using a recursive method or thread background, but it did not help.
My code is:
private void Andon_Load(object sender, EventArgs e)
{
LoadGrid();
}
private void LoadGrid()
{
DataTableWorkCall cdtwc = new DataTableWorkCall();
DataTable dtPBList = new DataTable();
dtPBList = cdtwc.CreatePendingWorkCall();
DataTableWorkCall.GetDataTableNew = dtPBList;
if (DataTableWorkCall.GetDataTableNew != DataTableWorkCall.GetDataTableOld)
{
if (DataTableWorkCall.GetDataTableNew.Rows.Count > 0)
{
DataTableWorkCall.GetDataTableOld = DataTableWorkCall.GetDataTableNew;
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
DataView dv = new DataView(DataTableWorkCall.GetDataTableNew);
dv.Sort = "workCallOpenDate DESC";
dgvAndon.DataSource = dv;
lblRefreshDate.Text = "Atualizado em: " + DateTime.Now;
existData = true;
}
else
{
if (this.WindowState == FormWindowState.Normal)
this.WindowState = FormWindowState.Minimized;
music.Clear();
music.StopSound();
lblRefreshDate.Text = "Atualizado em: " + DateTime.Now;
existData = false;
}
this.Activate();
//LoadGrid();
}
else
{
if (this.WindowState == FormWindowState.Normal)
this.WindowState = FormWindowState.Minimized;
lblRefreshDate.Text = "Atualizado em: " + DateTime.Now;
existData = false;
LoadGrid();
}
}
这不能奏效,谁能帮助我?