Forgive the lack of poor code my C# skills are very limited.
Currently sharing a large BusinessBindingSource. This allow me to load the data once and then use it on diverse forms without having to reload the data on each form. The underlying data is mostly static so this works very well.
Currently using the following method to share the data .
Form1
Form2.SharedBusinessSourceProducts = _sharedBusinessSourceProducts;
Form2.ShowDialog();
Form2
private BusinessBindingSource _sharedBusinessSourceProducts;
public BusinessBindingSource SharedBusinessSourceProducts
{
get
{
return _sharedBusinessSourceProducts;
}
set
{
_sharedBusinessSourceProducts = value;
}
}
when I access the data in form2 I use (their must be a nicer way
)
// move to correct row
_sharedBusinessSourceProducts.BusinessObject.SeekToPrimaryKey(productID);
// get column of field QtyInBundle
int QtyInBundleidx = _sharedBusinessSourceProducts.BusinessObject.CurrentRow.Table.Columns.IndexOf("QtyInBundle");
// get value
qtyInBundle = (Int32)_sharedBusinessSourceProducts.BusinessObject.CurrentRow.ItemArray[QtyInBundleidx];
isn't their a way I could just access the field name directly and do something like (assuming that the base BO is called BaseProductsBO)
qtyInBundle = _sharedBusinessSourceProducts.BaseProductsBO.QtyInBundle;
Basically I would like to bypass the whole getting the index of the field and just use the "typical" access via the BO.
I used to used the BO directly and have a shared SharedDataTableKey set but this caused some performance issues used a lot more memory and strangely not all of the memory would get returned after the form disposal.