'Declaration Public Shared Function FromControl( _ ByVal control As Control _ ) As UltraPopupControlContainer
public static UltraPopupControlContainer FromControl( Control control )
The FromControl method will return the UltraPopupControlContainer instance that is currently displaying the specified control or an ancestor of the specified control.
Note The popup window must be displayed or the associated UltraPopupControlContainer will not be available from this method.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.Misc Private Sub ultraPopupControlContainer1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles ultraPopupControlContainer1.Closed ' The Closed event is invoked when the ' popup has been closed and can be used to ' destroy the control, perform an action, etc. System.Diagnostics.Debug.WriteLine("Closed") End Sub Private Sub ultraPopupControlContainer1_Opened(ByVal sender As Object, ByVal e As System.EventArgs) Handles ultraPopupControlContainer1.Opened ' The Opened event is invoked after the popup ' has been displayed and can be used to further ' initialize the popup ' For example, you can set focus to the control it displayed ' Dim popup As UltraPopupControlContainer = CType(sender, UltraPopupControlContainer) ' the control that will be displayed can be initialized here If Not popup.PopupControl.ContainsFocus Then popup.PopupControl.Focus() End If End Sub Private Sub ultraPopupControlContainer1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ultraPopupControlContainer1.Opening Dim popup As UltraPopupControlContainer = CType(sender, UltraPopupControlContainer) Dim tree As TreeView = Me.treeList ' the control that will be displayed can be initialized here If Not popup.PopupControl Is tree Then popup.PopupControl = tree End If ' this Opening event will normally be used to initialize ' the control that will be dropped down Me.InitializeDropDownTree(tree) End Sub Private Sub InitializeDropDownTree(ByVal tree As TreeView) ' initialize the tree that we will be dropping down ' clear any existing nodes tree.Nodes.Clear() ' allow for full row selection tree.FullRowSelect = True tree.ShowLines = False tree.ShowRootLines = False ' only show a single border tree.BorderStyle = BorderStyle.FixedSingle ' create the nodes tree.Nodes.Add("New") tree.Nodes.Add("Open Existing") tree.Nodes.Add("Open Recent") ' select the first node tree.SelectedNode = tree.Nodes(0) ' size the control so it shows all the nodes Dim top As Integer = tree.Nodes(0).Bounds.Top Dim bottom As Integer = tree.Nodes(tree.Nodes.Count - 1).Bounds.Bottom tree.ClientSize = New Size(tree.ClientSize.Width, bottom - top) End Sub Private Sub treeList_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles treeList.KeyDown ' when the enter key is pressed invoke ' the tree's Click event If e.KeyCode = Keys.Return Then Me.InvokeOnClick(Me.treeList, EventArgs.Empty) ElseIf e.KeyCode = Keys.Escape Then ' then get the popup control container that is ' displaying the tree and close it Dim popup As UltraPopupControlContainer = UltraPopupControlContainer.FromControl(CType(sender, Control)) If Not popup Is Nothing Then popup.Close() End If End If End Sub Private Sub treeList_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeList.Click Dim tree As TreeView = CType(sender, TreeView) ' get the selected node and perform some action on it Dim node As TreeNode = tree.SelectedNode System.Diagnostics.Debug.WriteLine("Node Clicked:" + node.Text) ' then get the popup control container that is ' displaying the tree and close it Dim popup As UltraPopupControlContainer = UltraPopupControlContainer.FromControl(tree) If Not popup Is Nothing Then popup.Close() End If End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.Misc; private void ultraPopupControlContainer1_Closed(object sender, System.EventArgs e) { // The Closed event is invoked when the // popup has been closed and can be used to // destroy the control, perform an action, etc. System.Diagnostics.Debug.WriteLine("Closed"); } private void ultraPopupControlContainer1_Opened(object sender, System.EventArgs e) { // The Opened event is invoked after the popup // has been displayed and can be used to further // initialize the popup // For example, you can set focus to the control it displayed // UltraPopupControlContainer popup = sender as UltraPopupControlContainer; // the control that will be displayed can be initialized here if (!popup.PopupControl.ContainsFocus) popup.PopupControl.Focus(); } private void ultraPopupControlContainer1_Opening(object sender, System.ComponentModel.CancelEventArgs e) { UltraPopupControlContainer popup = sender as UltraPopupControlContainer; TreeView tree = this.treeList; // the control that will be displayed can be initialized here if (popup.PopupControl != tree) popup.PopupControl = tree; // this Opening event will normally be used to initialize // the control that will be dropped down this.InitializeDropDownTree(tree); } private void InitializeDropDownTree(TreeView tree) { // initialize the tree that we will be dropping down // clear any existing nodes tree.Nodes.Clear(); // allow for full row selection tree.FullRowSelect = true; tree.ShowLines = false; tree.ShowRootLines = false; // only show a single border tree.BorderStyle = BorderStyle.FixedSingle; // create the nodes tree.Nodes.Add("New"); tree.Nodes.Add("Open Existing"); tree.Nodes.Add("Open Recent"); // select the first node tree.SelectedNode = tree.Nodes[0]; // size the control so it shows all the nodes int top = tree.Nodes[0].Bounds.Top; int bottom = tree.Nodes[tree.Nodes.Count - 1].Bounds.Bottom; tree.ClientSize = new Size(tree.ClientSize.Width, bottom - top); } private void treeList_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { // when the enter key is pressed invoke // the tree's Click event if (e.KeyCode == Keys.Return) this.InvokeOnClick(this.treeList, EventArgs.Empty); else if (e.KeyCode == Keys.Escape) { // then get the popup control container that is // displaying the tree and close it UltraPopupControlContainer popup = UltraPopupControlContainer.FromControl(sender as Control); if (popup != null) popup.Close(); } } private void treeList_Click(object sender, System.EventArgs e) { TreeView tree = sender as TreeView; // get the selected node and perform some action on it TreeNode node = tree.SelectedNode; System.Diagnostics.Debug.WriteLine("Node Clicked:" + node.Text); // then get the popup control container that is // displaying the tree and close it UltraPopupControlContainer popup = UltraPopupControlContainer.FromControl(tree); if (popup != null) popup.Close(); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2