/// <summary> /// Attach this form to the given FluentListView /// </summary> public void Bind(AdvancedListView olv, IOverlay overlay) { if (objectListView != null) { Unbind(); } objectListView = olv; Overlay = overlay; mdiClient = null; mdiOwner = null; if (objectListView == null) { return; } // NOTE: If you listen to any events here, you *must* stop listening in Unbind() objectListView.Disposed += new EventHandler(objectListView_Disposed); objectListView.LocationChanged += new EventHandler(objectListView_LocationChanged); objectListView.SizeChanged += new EventHandler(objectListView_SizeChanged); objectListView.VisibleChanged += new EventHandler(objectListView_VisibleChanged); objectListView.ParentChanged += new EventHandler(objectListView_ParentChanged); // Collect our ancestors in the widget hierachy if (ancestors == null) { ancestors = new List <Control>(); } var parent = objectListView.Parent; while (parent != null) { ancestors.Add(parent); parent = parent.Parent; } // Listen for changes in the hierachy foreach (var ancestor in ancestors) { ancestor.ParentChanged += new EventHandler(objectListView_ParentChanged); var tabControl = ancestor as TabControl; if (tabControl != null) { tabControl.Selected += new TabControlEventHandler(tabControl_Selected); } } // Listen for changes in our owning form Owner = objectListView.FindForm(); myOwner = Owner; if (Owner != null) { Owner.LocationChanged += new EventHandler(Owner_LocationChanged); Owner.SizeChanged += new EventHandler(Owner_SizeChanged); Owner.ResizeBegin += new EventHandler(Owner_ResizeBegin); Owner.ResizeEnd += new EventHandler(Owner_ResizeEnd); if (Owner.TopMost) { // We can't do this.TopMost = true; since that will activate the panel, // taking focus away from the owner of the listview NativeMethods.MakeTopMost(this); } // We need special code to handle MDI mdiOwner = Owner.MdiParent; if (mdiOwner != null) { mdiOwner.LocationChanged += new EventHandler(Owner_LocationChanged); mdiOwner.SizeChanged += new EventHandler(Owner_SizeChanged); mdiOwner.ResizeBegin += new EventHandler(Owner_ResizeBegin); mdiOwner.ResizeEnd += new EventHandler(Owner_ResizeEnd); // Find the MDIClient control, which houses all MDI children foreach (Control c in mdiOwner.Controls) { mdiClient = c as MdiClient; if (mdiClient != null) { break; } } if (mdiClient != null) { mdiClient.ClientSizeChanged += new EventHandler(myMdiClient_ClientSizeChanged); } } } UpdateTransparency(); }