Updating grid from custom delegate

V

VM

How can I update a grid from within a delegate call?

Here's some of my code:

delegate void loadFileDelegate(string sFileName);
public void DisplayAuditFile(string sFileName)
{
loadFileDelegate LoadAuditFileToTable = new
loadFileDelegate(loadAuditFileToTable);
LoadAuditFileToTable.BeginInvoke (sFileName, null, null);
}

private void loadAuditFileToTable(string sFileName)
{
rowAudit = zmAudit.OpenAuditAZMFileToView(ref isEndOfFile, ref
iRowsProcessed);
if (!isEndOfFile)
{
_table_auditAddress.Rows.Add(rowAudit);
ShowProgress(iRowsProcessed);
}
}
private void ShowProgress(int iRowsProcessed)
{
if(domainUpDown_goTo.InvokeRequired == false )
{
domainUpDown_goTo.Text = iRowsProcessed.ToString();
if (iRowsProcessed % 1000 == 0)
{
/* I want to update the grid with these 1000 records in the
table */
}
}
else
{
ShowProgressDelegate showProgress = new
ShowProgressDelegate(ShowProgress);
BeginInvoke(showProgress, new object[] {iRowsProcessed });
}
}


Thanks.
 
M

Miha Markic [MVP C#]

Hi,

You should use similar code as for ShowProgress (check if invoke is
required...).
 
V

VM

How would I actually display the 1000 records in the grid? Should I use
datagrid.datasource or refresh or...?

Thanks,


Miha Markic said:
Hi,

You should use similar code as for ShowProgress (check if invoke is
required...).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

VM said:
How can I update a grid from within a delegate call?

Here's some of my code:

delegate void loadFileDelegate(string sFileName);
public void DisplayAuditFile(string sFileName)
{
loadFileDelegate LoadAuditFileToTable = new
loadFileDelegate(loadAuditFileToTable);
LoadAuditFileToTable.BeginInvoke (sFileName, null, null);
}

private void loadAuditFileToTable(string sFileName)
{
rowAudit = zmAudit.OpenAuditAZMFileToView(ref isEndOfFile, ref
iRowsProcessed);
if (!isEndOfFile)
{
_table_auditAddress.Rows.Add(rowAudit);
ShowProgress(iRowsProcessed);
}
}
private void ShowProgress(int iRowsProcessed)
{
if(domainUpDown_goTo.InvokeRequired == false )
{
domainUpDown_goTo.Text = iRowsProcessed.ToString();
if (iRowsProcessed % 1000 == 0)
{
/* I want to update the grid with these 1000 records in the
table */
}
}
else
{
ShowProgressDelegate showProgress = new
ShowProgressDelegate(ShowProgress);
BeginInvoke(showProgress, new object[] {iRowsProcessed });
}
}


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top