Actually I use a work around to initialize some event handlers. This work around is based on the routine to assign the ledger number
public Int32 LedgerNumber
{
set
{
FLedgerNumber = value;
ucoBatches.LoadBatches(FLedgerNumber);
// some code ...
ucoJournals.WorkAroundInitialization();
ucoTransactions.WorkAroundInitialization();
}
}
And in the ucoTransactions I use a routine to implement an event handler to all editable controls
public void WorkAroundInitialization()
{
txtCreditAmount.Validated += new EventHandler(ControlHasChanged);
txtDebitAmount.Validated += new EventHandler(ControlHasChanged);
cmbDetailCostCentreCode.Validated += new EventHandler(ControlHasChanged);
cmbDetailAccountCode.Validated += new EventHandler(ControlHasChanged);
cmbDetailKeyMinistryKey.Validated += new EventHandler(ControlHasChanged);
txtDetailNarrative.Validated += new EventHandler(ControlHasChanged);
txtDetailReference.Validated += new EventHandler(ControlHasChanged);
dtpDetailTransactionDate.Validated += new EventHandler(ControlHasChanged);
}
Inside of ControlHasChanged I only call FocusedRowChanged a routine which allready exists in the automatic code part.
private void ControlHasChanged(System.Object sender, EventArgs e)
{
SourceGrid.RowEventArgs egrid = new SourceGrid.RowEventArgs(-10);
FocusedRowChanged(sender,egrid);
}
This additional code generates an "click' onto the selected grid line which iselfs calls all refresh and recalculate routines.
Hint: The "-10" is not used - in normal case it should be the number/index of the line.
That means: Independently of the kind of leaving a control the data are stored properly before a new control is seleted.
I think it may be a good idea to implement this technique in the automatic code.