Lin a DataTable Coumn to a Object.Property
I am currently working on some sort of downloadmanager as part of a bigger
project. For each download I use a custom class FileTransfer that is
responsible for the download of a single file.
When large quantities of files are downloaded, they are stored in a
List<FileTransfer> within the DownloadManager class.
What I want is a live representation of those downloads in a DataGridView.
I now manually add all FileTransfers to a DataTable linked to a
DataGridView. This is static though, so the progress needs to be updated
manually.
I have created this function:
for (int i = 0; i < transfers.Count; i++)
{
if (transfers[i].State == DownloadState.Active)
{
DataRow row = null;
try
{
row = dtTransfers.Select("ID=" + transfers[i].ID)[0];
}
catch { }
if (row != null)
row["progress"] = transfers[i].Progress;
}
}
This is way to dirty, error-prone, to time-consuming, etc.
Is there a way to have to value in the DataTable change automaticly when
the FileTransfer.Progress value changes?
No comments:
Post a Comment