Catching the event that raises the Save Changes dialog


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Well, I've got the cussing down.



Looking at the call stack though, the only code being called is .NET code. Neither my code or any Tx Text control code is being called at all. I was thinking this was related to validation and hoping somebody who understands it better than I could explain why validation code is setting properties?



Unless you saying that this is related to how Tx Text instantiates itself, that it adds handlers to that call this .NET code?!?? That would be just lovely Sad
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, without getting my hands on it I cannot tell you exactly what is going on within your code and control.  We use the TxTextControl in one area of our medical application and we had to write all sorts of code around it due to the nature of how that control instantiates itself.  So giving you a straight answer just isn't going to happen on this one, everytime Ihave used that TxTextControl I cuss a little....debug a lot...and write additional code to make it work....the ability to work with DOC files without requiring Word to be installed is worth the trouble, but there are some definite idiosyncrasies with their control.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
...which you covered in class...as I now recall. BigGrin



OK, this is apparently all being cased by Winforms validation code. What I don't get is that it is setting property values here. I.e. the validation code is setting properties. Any idea why?



Here is some of the call stack up to the set_FormattedText:





>TxTextTest.exe!TxTextTest.TextEditorControl.set_FormattedText(String value = "...") Line 89 + 0xb bytesBasic

[Native to Managed Transition]

[Managed to Native Transition]

System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {TxTextTest.TextEditorControl}, object value = "...") + 0x10c bytes

System.Windows.Forms.dll!System.Windows.Forms.Binding.SetPropValue(object value) + 0xca bytes

System.Windows.Forms.dll!System.Windows.Forms.Binding.PullData(bool reformat, bool force) + 0x13b bytes

System.Windows.Forms.dll!System.Windows.Forms.Binding.Target_Validate(object sender, System.ComponentModel.CancelEventArgs e = {System.ComponentModel.CancelEventArgs}) + 0x1b bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.OnValidating(System.ComponentModel.CancelEventArgs e) + 0x4c bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.PerformControlValidation(bool bulkValidation = false) + 0x45 bytes

System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.ValidateThroughAncestor(System.Windows.Forms.Control ancestorControl = {TxTextTest.TextEditorUIControl}, bool preventFocusChangeOnError = true) + 0xff bytes

System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.ValidateInternal(bool checkAutoValidate, out bool validatedControlAllowsFocusChange) + 0x12f bytes

System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.ValidateInternal(bool checkAutoValidate = true, out bool validatedControlAllowsFocusChange = false) + 0x9e bytes

System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.Validate(bool checkAutoValidate) + 0x15 bytes

System.Windows.Forms.dll!System.Windows.Forms.Form.WmClose(ref System.Windows.Forms.Message m = {msg=0x10 (WM_CLOSE) hwnd=0xc081c wparam=0x0 lparam=0x0 result=0x0}) + 0x87 bytes

System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) + 0x1d5 bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativewindow.OnMessage(ref System.Windows.Forms.Message m) + 0xd bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativewindow.WndProc(ref System.Windows.Forms.Message m) + 0xbf bytes

System.Windows.Forms.dll!System.Windows.Forms.Nativewindow.Callback(System.IntPtr hWnd, int msg = 16, System.IntPtr wparam, System.IntPtr lparam) + 0x68 bytes

[Native to Managed Transition]

[Managed to Native Transition]

System.Windows.Forms.dll!System.Windows.Forms.Nativewindow.DefWndProc(ref System.Windows.Forms.Message m) + 0x43 bytes

...etc. for another 20 calls or so

TxTextTest.exe!TxTextTest.AppMain.Main() Line 19 + 0x6 bytesBasic




So, I'm hoping you can help me understand what the heck is going on, or point me in the right direction to understand this.
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you go to the Tools -> Options -> Debug uncheck the JustMyCode setting, you'll get the code within the CallStack for the TXText control... it might give you more info as to why it thinks that the binding needs to be updated...
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, I did that and the stack trace indicated the following were called (last called on top):



Form2.BusinessBindingSource1_ListChanged2

[External Code]

CustomerNotesBO.set_cn_note

CustomerNotesBO.Field_cn_note_Descriptor.SetValue

[External Code]

AppMain.Main

[External Code]



The 'set_cn_note' is were the BO is getting dirtied. I'm wondering why it is getting called? It isn't dirty, so why is it updating?



StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Drop a BusinessBindingSource on the form and set it's business object to the BO you want to watch.  Then add a handler to the BBS's ListChanged event.  It will get raised whenever a property on the business object is set.  So, put your breakpoint in that handler, and you'll be able to look at the CallStack (like in class) to see what is getting called down the line to change the data within the business object to make it dirty.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm using the IBusinessBindable interface to wrap the Tx Text control. Because of something I'm doing (which is unknown at this point), every time I go to close the form with this control, I get prompted to save changed, even if all I do is open and close the form.



I put a button on the form to show me if the BO is dirty. It isn't until I close the form (i.e. I can open the form, click the button - its not dirty, then close the form - it is dirty (checked in the closing event of the form), I get the save changes dialog, cancel out to close). So before the form closing event, something is making the BO dirty.



Soooo... I'm wondering what event to handle to see what is happening as I close the form. Then I could walk through it and see what my mistake is. I'm already handling the BeforeSave, but that doesn't work, because this happens before that event is raised.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search