In Visual Studio using Infragistics, C#, and WinForms, how to close the tab when the user clicks anywhere in the form? I have multiple forms opened on the same page at the same time. A particular Tab (let's say "DecorDesign" is the tab name) should be closed when the user clicks on anywhere in those multiple forms.
Is there any way to close the tab, when the focus on the tab is lost? Or any event handler for this scenario?
This answer should work with or without Infragistics. As I understand it, you want to be notified of a mouse click occurring anywhere in any form of your app and when that happens you want to be able to inspect it to determine whether the click occurred specifically in "the tab" (or not). Implementing
IMessageFilterfor the main form of your app should give the expected behavior as shown:When you receive the event, look at
senderto see if it's a match for "the tab".The implementation of
IMessageFilterconsists of a single method, and here the click "event" (the WM_LBUTTONDOWN message) will be detected so that the universal custom event can be raised.Mock example of other forms