Hi !
I'm trying to update a datasource linked to a texteditor, while i'm changing the value inside this texteditor.
But the data in the datasource remains the same, until I quit the field.
I guess that the synchronizing magic happens only on the "on leave texteditor" event... But is there anyway to configure that ? What if I need the sync to happen on the "on value changed" event (without building my own BindingSource objecy) ?
Thanks
Dam
You could add a ValueChanged event handler and call bindingSource1:Assign(), or set the bindingSource1:InputValue if you wanted to.
But why do you need to assign every input character into the TT?
-- peter
I'm already doing an Assign() on the "value change" event.
If I try removing it, the data is not updated even on leaving the cell...
I need it, for axample, in order to save data I've juste typed by clicking on a save button with the property "accept focus" set to false (which means the field has not been leaved).
Something like
oTextBox:DataBindings["Text"]:WriteValue().
should do. Let me know if not, then I'll look up the exact code.
froy schrieb:
I need it, for axample, in order to save data I've juste typed by clicking on a save button with the property "accept focus" set to false (which means the field has not been leaved).
This is the code that we are using for that exact purpose:
/*------------------------------------------------------------------------------
Purpose: Recursive call WriteValue method of all DataBinding objects.
Initialy called by SaveChanges () of SmartViewerControl.
Parameters:
poControl - System.Windows.Forms.Control
Current Container to perform Action on.
Notes: This ensures, that the currently focussed field values are
written to the bindingsource as well (toolbar buttons do
not cause a Leave to a textbox) .
------------------------------------------------------------------------------*/
METHOD PROTECTED VOID RecurseBindingWriteValue(poControl AS Control):
DEFINE VARIABLE oControl AS System.Windows.Forms.Control NO-UNDO.
DEFINE VARIABLE oBindingsCollection AS System.Windows.Forms.BindingsCollection NO-UNDO .
DEFINE VARIABLE cPropertyName AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
DO i = 0 TO poControl:Controls:Count - 1:
/* Write Changes to the current field */
ASSIGN
oControl = poControl:Controls[i]
oBindingsCollection = oControl:DataBindings.
DO j = 0 TO oControl:DataBindings:Count - 1:
ASSIGN
cPropertyName = oBindingsCollection:Item[j]:PropertyName .
oControl:DataBindings[cPropertyName]:WriteValue().
END.
IF oControl:Controls:Count > 0 THEN
RecurseBindingWriteValue (oControl) .
END.
RETURN.
END METHOD.
Thank you everybody for your answers ! It helps on two points :
- I'm not alone with thoses questions
- I got an answer
Wouh !