One method is to
Setup a class which has properties to represent information on your form which implements INotifyPropertyChanged interface. In the following is an example with a single property, for each property needed repeat what has been done with ProductName.
public class Product : INotifyPropertyChanged
{
private string _productName;
public string ProductName
{
get => _productName;
set
{
_productName = value;
OnPropertyChanged();
}
}
public override string ToString() => ProductName;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Next, have a class responsible for data operations that has methods such as get all data, get data by id, delete by id, find by id, save by id etc.
In your form request data from the data operation class, assign to a BindingList which becomes the data source of a BIndingSource which can be used to bind properties to controls while the ProgressBar you can remember via something like this and in the set
set the property value for the current item.
public partial class Form1 : Form, INotifyPropertyChanged
{
private int _percentDone = 50;
public Form1()
{
InitializeComponent();
progressBar1.Maximum = 100;
progressBar1.DataBindings.Add("Value", this, "PercentDone");
}
public int PercentDone
{
get => _percentDone;
set
{
_percentDone = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
In some cases you may need to subscribe to the ListChanged event of the BindingList.
The above may appear like a lot of work and complex but the truth is, it's work and only complex until you take time to understand everything.