StrataFrame Forum

Save data problem

http://forum.strataframe.net/Topic27242.aspx

By dgsoft - 5/27/2010

Hi,

I have a problems with controls and Save data.

The problem is, for example - I have RichTextEditor and Bind BO and BO field to it.

When I change text and click Save toolbar button - the object revert value, because it still in focus.

If I click mouse to another control or leave control with TAB, then Save works.



One idea to emulate TAB keypress before Save Smile but maybe exist more good way for this Smile



Thanks

Denis
By Ivan George Borges - 5/27/2010

Hey Denis.

I have created an Invisible textbox in my BaseForm for situations like that. So I also have a BeforeSave that will take care of getting the focus out of the current control:

    Private Sub YourBaseForm_BeforeSave(ByVal e As _
        MicroFour.StrataFrame.Data.BeforeSaveUndoByFormEventArgs) Handles Me.BeforeSave
        '-- Change focus to pre-built control in order to validate control where focus
        '-- is set in any form, before saving. This is needed if user saves the form
        '-- without leaving control. If Validate has code, it will be executed first,
        '-- refreshing any related contents before saving, otherwise save will occur first.
        Me.txtMoveFocusBeforeSave.Visible = True
        Me.txtMoveFocusBeforeSave.Focus()
        Me.txtMoveFocusBeforeSave.Visible = False
    End Sub

By dgsoft - 5/27/2010

Hi Ivan,

The idea is ok, but it does not work.

the focus control must be real visible on the form? Maybe problem the control is behind another controls?

Code processed (debugger) , but control revert value during save.



Thanks

Denis
By Ivan George Borges - 5/28/2010

Hmm... I am glad it works here! BigGrin

Yeah, as you can notice, I set the control Visible to True just before setting Focus to it, and then back to False.

By the way, just to test, I created a new StrataFrame project without any of this, dropped a RichTextbox on a form, made it bound to a BO property, run it, typed text into it and it saved just fine, without ever leaving the control. You might need to have a look if there isn't anything else going on in your code or you could write a small sample that shows this behaviour and post it here so we can have a look.