This behavior might be "By Design" and if it is I am hoping there's a (an easy) way around it.
Background:
I have a form that is being used as a custom Find / Replace dialog. As such I am showing the form as non-modal with the topmost property set to true and using the Form.Activated (and possibly the Form.Deactivate) event(s) to make changes to the search area (as the user may have changed their selection(s) while off the Find/Replace dialog form).
Problem:
The Form.Deactivate event of the Dialog Form never fires if the user clicks on the UltraToolBar on my form. They can click anywhere else on the Main (parent) form or in/on any of the nested user controls (which is where my ToolBar actually resides) and the events fire. It is only when they click on the toolbar that the dialog form never deactivates.
I have created a test/sample app that reproduces this and attached it.
Form1 simulates the Main Form with the ToolBar and Form2 simulates the dialog. Again if you click anywhere on Form1, Form2 deactivates except if you click on the toolbar.
Thanks in advance for any assistance you can provide.
Steve
Hello Steve,
Since the toolbar manager does not take focus, the main form will not activate unless had an editor on the toolbar manager. An editor would steal focus, deactivate the second form and activate the main form again.
I am glad you found a way around this behavior but it's expected.
Let me know if you have any quesitons regarding this matter.
Michael,
I chose not to use ShowDialog because I do not wish the Find/Replace dialog to be modal but rather to allow the user to move back and forth between the main form and the Find/Replace dialog (much like we can in the Visual Studio environment).
Also similar to the VS IDE - certain things need to happen / change / update when the user leaves the F/R dialog and then returns to it. Since a form will not take focus if there are controls on it that can take focus, I cannot use the focus related events of the F/R dialog form which is why I needed the Activated / Deactivate events.
For my particular use case - I was able to create a work around by setting focus to the underlying user control that contains the toolbar during the ToolClicked event which in turn causes my F/R Dialog to deactivate.
As stated before I'm not sure if it is by design or a bug, but it is rather quirky that I can click on other Infragistics controls (UltraGrid) as well as default VS controls on the same UserControl (form) and everything takes focus away from the dialog form except for the ToolBar.
Thanks for your time and assistance.
If you wish to show the second form as a dialog I recommend calling ShowDialog instead of Show and/or passing the main form as an Owner.
Change _newfrm.Show(Me)
to _newfrm.ShowDialog()
Let me know if you have any questions regarding this matter.