datagrid and custom collection object synchronization

  • Thread starter Thread starter Sanjin
  • Start date Start date
S

Sanjin

I have custom collection that is bind to the System.Windows.Forms.DataGrid.

My custom collection business object has property Quantity.

public event System.ComponentModel.PropertyChangedEventHandler
QuantityChanged;
private int quantity;
[System.ComponentModel.Bindable(true)]
public int Quantity
{
get { return quantity; }
set
{
if (quantity != value)
{
quantity = value;
if (QuantityChanged != null)
QuantityChanged(this, new
System.ComponentModel.PropertyChangedEventArgs("Quantity") );
}
}
}

Property Quantity is modified through code and datagrid quantity is not
automatically refreshed (QuantityChanged is always null)

Is it possible to somehow accomplish datagrid and collection synchronization
automatically?

I know that I can do something like that, but I want nicer solution (pseudo
code):

MyCollection.QuantityChanged += new
PropertyChangedEventHandler(refresh_method);

....

private void refresh_method()
{
myDataGrid.Refresh();
}

Thanks in advance


Sanjin
 
Back
Top