if you are trying to update a database. From a listbox i would suggest creating a dataset.
for instance, if your doing something for each item in a database. Copy the database dataset, by creating new dataset and declaring by mainDataset.
for example:
// the gridview dataset is dataset1
BackgroundWorker_DoWork(object sender, DoWorkArgs e)
{
Dataset dataset2 = dataset1;
foreach(DataGridViewRow row in GridView)
{
//do some work
dataset2.Main.AddMainRow(values to add);
dataset2.AcceptChanges();
}
}
BackgroundWorker_WorkCompleted(object sender, DoWorkArgs e)
{
//Forces UI thread to valitdate dataset
dataset2.update();
// Sets file Path
string FilePath = "Some Path to file";
dataset2.writexml(FilePath, XmlWriteOptions.WriteSchema);
//if you use xml to fill your dataset filepath to write should equal path to dataset1 xml
dataset1.Refresh();
}