示例#1
0
        /// <summary>
        /// Shows drop down control for the given tree node
        /// </summary>
        /// <param name="treeNode">Tree Node to show drop down control at</param>
        private bool ShowComboBox(DropDownTreeNode treeNode)
        {
            if (treeNode == null)
            {
                return(false);
            }

            this.m_CurrentNode         = treeNode;
            this.m_CurrentSelectionIdx = this.m_CurrentNode.ComboBox.SelectedIndex;

            // Need to add the node's ComboBox to the TreeView's list of controls for it to work
            this.Controls.Add(this.m_CurrentNode.ComboBox);

            // Set the bounds of the ComboBox, with a little adjustment to make it look right
            this.m_CurrentNode.ComboBox.SetBounds(
                this.m_CurrentNode.Bounds.X - 1,
                this.m_CurrentNode.Bounds.Y - 2,
                AimWinFormsUtil.CalculateComboBoxDropdownWidth(this.m_CurrentNode.ComboBox),
                //this.m_CurrentNode.Bounds.Width + 25,
                this.m_CurrentNode.Bounds.Height);

            // Listen to the SelectedValueChanged event of the node's ComboBox
            this.m_CurrentNode.ComboBox.SelectedValueChanged += ComboBox_SelectedValueChanged;
            this.m_CurrentNode.ComboBox.DropDownClosed       += ComboBox_DropDownClosed;
            this.m_CurrentNode.ComboBox.BackColor             = Color.DeepPink;

            // Now show the ComboBox
            this.m_CurrentNode.ComboBox.Show();
            this.m_CurrentNode.ComboBox.DroppedDown = true;

            return(true);
        }
        private void _cmbAnnotationType_DropDown(object sender, EventArgs e)
        {
            var cmbBox = sender as ComboBox;

            if (cmbBox != null)
            {
                cmbBox.DropDownWidth = AimWinFormsUtil.CalculateComboBoxDropdownWidth(cmbBox);
            }
        }
        private void OnDropDown(object sender, EventArgs e)
        {
            // Adjust dropdown width to be as large as the longest item's width
            ComboBox cmbBox = sender as ComboBox;

            if (cmbBox != null)
            {
                cmbBox.DropDownWidth = AimWinFormsUtil.CalculateComboBoxDropdownWidth(cmbBox);
            }
        }