示例#1
0
文件: SelectBox.cs 项目: Pumpet/Robin
 protected void StartValues()
 {
     unlockedColor  = BackColor;
     unlockedStyle  = ComboBoxStyle.DropDown;
     DropDownHeight = 1;
     DropDownWidth  = 1;
 }
示例#2
0
        public void ChildListAccessibleObject_FragmentNavigate_PreviousSibling_ReturnsExpected(
            ComboBoxStyle comboBoxStyle,
            bool createControl,
            bool droppedDown)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            if (createControl)
            {
                comboBox.CreateControl();
            }

            comboBox.DroppedDown = droppedDown;
            AccessibleObject previousItem = comboBox.ChildListAccessibleObject
                                            .FragmentNavigate(UiaCore.NavigateDirection.PreviousSibling) as AccessibleObject;

            AccessibleObject expectedItem = comboBoxStyle == ComboBoxStyle.Simple
                ? comboBox.ChildListAccessibleObject
                : null;

            Assert.Equal(expectedItem, previousItem);
            Assert.True(comboBox.IsHandleCreated);
        }
示例#3
0
        public void ChildListAccessibleObject_FragmentNavigate_NextSibling_ReturnsExpected(
            ComboBoxStyle comboBoxStyle,
            bool createControl,
            bool droppedDown)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            if (createControl)
            {
                comboBox.CreateControl();
            }

            comboBox.DroppedDown = droppedDown;
            AccessibleObject nextItem = comboBox.ChildListAccessibleObject
                                        .FragmentNavigate(UiaCore.NavigateDirection.NextSibling) as AccessibleObject;

            AccessibleObject expectedItem = comboBoxStyle == ComboBoxStyle.DropDownList
                ? comboBox.ChildTextAccessibleObject
                : comboBox.ChildEditAccessibleObject;

            Assert.Equal(expectedItem, nextItem);
            Assert.True(comboBox.IsHandleCreated);
        }
示例#4
0
        public void ComboBoxChildEditUiaProvider_FragmentNavigate_NextSibling_ReturnsExpected(
            ComboBoxStyle comboBoxStyle,
            bool createControl,
            bool droppedDown)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            if (createControl)
            {
                comboBox.CreateControl();
            }

            comboBox.DroppedDown = droppedDown;
            AccessibleObject nextItem = comboBox.ChildEditAccessibleObject
                                        .FragmentNavigate(UiaCore.NavigateDirection.NextSibling) as AccessibleObject;

            AccessibleObject expectedItem = comboBoxStyle != ComboBoxStyle.Simple
                ? ((ComboBox.ComboBoxAccessibleObject)comboBox.AccessibilityObject).DropDownButtonUiaProvider
                : null;

            Assert.Equal(expectedItem, nextItem);
            Assert.True(comboBox.IsHandleCreated);
        }
示例#5
0
        private void Init(IEnumerable <string> hints, ComboBoxStyle style, string value)
        {
            if (_control != null)
            {
                return;
            }

            ComboBox cbx = new ComboBox();

            cbx.AutoSize      = true;
            cbx.DropDownStyle = style;
            cbx.Anchor        = UIConst.AutoSize;

            if (hints != null)
            {
                foreach (string it in hints)
                {
                    cbx.Items.Add(it);
                }

                if (cbx.Items.Count > 0)
                {
                    cbx.SelectedIndex = 0;
                }
            }

            _control = cbx;
            Value    = value;
        }
示例#6
0
        public void DropDownButtonUiaProvider_FragmentNavigate_PreviousSibling_ReturnsExpected(
            ComboBoxStyle comboBoxStyle,
            bool createControl,
            bool droppedDown)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            if (createControl)
            {
                comboBox.CreateControl();
            }

            comboBox.DroppedDown = droppedDown;
            AccessibleObject previousItem = GetComboBoxAccessibleObject(comboBox).DropDownButtonUiaProvider
                                            .FragmentNavigate(UiaCore.NavigateDirection.PreviousSibling) as AccessibleObject;

            AccessibleObject expectedItem = comboBoxStyle == ComboBoxStyle.DropDownList
                ? comboBox.ChildTextAccessibleObject
                : comboBox.ChildEditAccessibleObject;

            Assert.Equal(expectedItem, previousItem);
            Assert.True(comboBox.IsHandleCreated);
        }
示例#7
0
        public void ChildListAccessibleObject_BoundingRectangle_ReturnsCorrectWidth_IfComboBoxIsScrollable(ComboBoxStyle comboBoxStyle)
        {
            const int expectedWidth = 100;

            using ComboBox comboBox = new()
                  {
                      DropDownStyle  = comboBoxStyle,
                      IntegralHeight = false
                  };
            comboBox.Items.AddRange(Enumerable.Range(0, 11).Cast <object>().ToArray());
            comboBox.CreateControl();

            if (comboBoxStyle == ComboBoxStyle.Simple)
            {
                comboBox.Size = new Size(expectedWidth, 150);
            }
            else
            {
                comboBox.Size           = new Size(expectedWidth, comboBox.Size.Height);
                comboBox.DropDownHeight = 120;
                comboBox.DroppedDown    = true;
            }

            UiaCore.IRawElementProviderFragment childListUiaProvider = comboBox.ChildListAccessibleObject;
            UiaCore.UiaRect actual = childListUiaProvider.BoundingRectangle;

            Assert.Equal(expectedWidth, actual.width);
        }
    }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctrl"></param>
        /// <param name="tv"></param>
        /// <param name="extra"></param>
        public static void BindTo(this ComboBox ctrl, TextValues tv, ExtraItems extra = ExtraItems.NoExtra
                                  , ComboBoxStyle style = ComboBoxStyle.DropDownList)
        {
            NotNull(ctrl, "ctrl");
            NotNull(tv, "tv");

            ctrl.Items.Clear();
            ctrl.DisplayMember = "Item1"; // name of Tuple.Item1
            ctrl.ValueMember   = "Item2"; // name of Tuple.Item2
            ctrl.DropDownStyle = style;

            if ((extra & ExtraItems.AddNone) != 0)
            {
                ctrl.Items.Add(Tuple.Create(Properties.Resources.ListControl_ItemNone, NoneValue));
            }
            if ((extra & ExtraItems.AddAll) != 0)
            {
                ctrl.Items.Add(Tuple.Create(Properties.Resources.ListControl_ItemAll, AllValue));
            }

            tv.ForEach(_ => ctrl.Items.Add(_));

            if (ctrl.Items.Count > 0)
            {
                ctrl.SelectedIndex = 0;
            }
        }
示例#9
0
        public ComboBox()
        {
            textEntry           = new TextBox();
            BackColor           = SystemColors.Window;
            BorderStyleInternal = BorderStyle.Fixed3D;
            dropDownStyle       = ComboBoxStyle.DropDown;
            integralHeight      = true;
            maxDropDownItems    = 8;
            dropDownWidth       = Width;
            updateCount         = 0;
            itemHeight          = FontHeight + 2;
            selectedIndex       = -1;
            SetStyle(ControlStyles.ResizeRedraw, true);
            textEntry.BorderStyle = BorderStyle.None;
            textEntry.TabStop     = false;
            textEntry.LostFocus  += new EventHandler(textentry_LostFocus);
            textEntry.GotFocus   += new EventHandler(textentry_GotFocus);
            this.Controls.Add(textEntry);

            popup = new PopupControl();
            popup.BorderStyleInternal = BorderStyle.FixedSingle;
            popup.BackColor           = SystemColors.Window;
            popup.PopDown            += new EventHandler(popup_PopDown);
            popup.Paint     += new PaintEventHandler(popup_Paint);
            popup.MouseDown += new MouseEventHandler(popup_MouseDown);
            popup.MouseMove += new MouseEventHandler(popup_MouseMove);
            popup.MouseUp   += new MouseEventHandler(popup_MouseUp);

            scrollbar               = new VScrollBar();
            scrollbar.Dock          = DockStyle.Right;
            scrollbar.BackColor     = SystemColors.Control;
            scrollbar.ValueChanged += new EventHandler(scrollbar_ValueChanged);
            popup.Controls.Add(scrollbar);
        }
示例#10
0
        /// <summary>
        /// 创建DataGridView扩展的ComboBox列
        /// </summary>
        /// <param name="_dgv">要创建列的DataGridView</param>
        /// <param name="_alignment">设置列的对齐方式</param>
        /// <param name="_columnName">列名</param>
        /// <param name="_headerText">标题名</param>
        /// <param name="_dataPropertyName">绑定数据源的字段名称</param>
        /// <param name="_toolTipText">TipText提示</param>
        /// <param name="_readOnly">设置列是否只读,true 只读,false 读写</param>
        /// <param name="_visible">设置列是否可见,true 显示,false 隐藏</param>
        /// <param name="_cboDataSource">绑定ComboBox的数据源</param>
        /// <param name="_displayMember">用于显示的字段名</param>
        /// <param name="_valueMember">绑定Value的字段名</param>
        /// <param name="_maxDropDownItems">设置显示最大的下拉项条数</param>
        /// <param name="_dropDownStyle">设置显示类型</param>
        /// <param name="_notEmpty">设置列是否为必填列,true 必填,false 非必填</param>
        /// <param name="_backColor">设置列的背景色,当_notEmpty为true时,此项为必需值,为false,此项可以为Color.Empty</param>
        /// <param name="_columnState">装载DataGridView可写可读、只读列的数据字典</param>
        public static void InitDgvComboBoxExColumn(DataGridView _dgv,
                                                   DataGridViewContentAlignment _alignment, string _columnName, string _headerText,
                                                   string _dataPropertyName, string _toolTipText, bool _readOnly, bool _visible,
                                                   DataTable _cboDataSource, string _displayMember, string _valueMember,
                                                   int _maxDropDownItems, ComboBoxStyle _dropDownStyle,
                                                   bool _notEmpty, Color _backColor, ref Dictionary <string, bool> _columnState)
        {
            DataGridViewComboBoxExColumn comboBoxExCol = new DataGridViewComboBoxExColumn();

            comboBoxExCol.HeaderCell.Style.Alignment = _alignment == 0 ? DataGridViewContentAlignment.MiddleLeft : _alignment;
            comboBoxExCol.Name             = _columnName;
            comboBoxExCol.HeaderText       = _headerText;
            comboBoxExCol.DataPropertyName = _dataPropertyName;
            comboBoxExCol.ToolTipText      = _toolTipText;
            comboBoxExCol.Visible          = _visible;
            comboBoxExCol.ReadOnly         = _readOnly;
            comboBoxExCol.DataSource       = _cboDataSource;
            comboBoxExCol.DisplayMember    = _displayMember;
            comboBoxExCol.ValueMember      = _valueMember;
            comboBoxExCol.MaxDropDownItems = _maxDropDownItems;
            comboBoxExCol.DropDownStyle    = _dropDownStyle;
            if (_notEmpty == true)
            {
                comboBoxExCol.DefaultCellStyle.BackColor = _backColor;
            }
            _columnState.Add(_columnName, _readOnly);
            _dgv.Columns.Add(comboBoxExCol);
        }
示例#11
0
		public ComboBox()
		{
			textEntry = new TextBox();
			BackColor = SystemColors.Window;
			BorderStyleInternal = BorderStyle.Fixed3D;
			dropDownStyle = ComboBoxStyle.DropDown;
			integralHeight = true;
			maxDropDownItems = 8;
			dropDownWidth = Width;
			updateCount = 0;
			itemHeight = FontHeight + 2;
			selectedIndex = -1;
			SetStyle(ControlStyles.ResizeRedraw, true);
			textEntry.BorderStyle = BorderStyle.None;
			textEntry.TabStop = false;
			textEntry.LostFocus += new EventHandler(textentry_LostFocus);
			textEntry.GotFocus += new EventHandler(textentry_GotFocus);
			this.Controls.Add(textEntry);
		
			popup = new PopupControl();
			popup.BorderStyleInternal = BorderStyle.FixedSingle;
			popup.BackColor = SystemColors.Window;
			popup.PopDown += new EventHandler(popup_PopDown);
			popup.Paint +=new PaintEventHandler(popup_Paint);
			popup.MouseDown+=new MouseEventHandler(popup_MouseDown);
			popup.MouseMove+=new MouseEventHandler(popup_MouseMove);
			popup.MouseUp+=new MouseEventHandler(popup_MouseUp);

			scrollbar = new VScrollBar();
			scrollbar.Dock = DockStyle.Right;
			scrollbar.BackColor = SystemColors.Control;
			scrollbar.ValueChanged+=new EventHandler(scrollbar_ValueChanged);
			popup.Controls.Add(scrollbar);
		}
示例#12
0
 protected override void OnDropDownStyleChanged(EventArgs e)
 {
     base.OnDropDownStyleChanged(e);
     if (!this.updatingStyle)
     {
         this.prevStyle = this.DropDownStyle;
     }
 }
        private ComboBox GetComboBoxWithMaxSize(ComboBoxStyle comboBoxStyle)
        {
            ComboBox comboBox = GetComboBox(comboBoxStyle);

            comboBox.Size          = new Size(100, 50);
            comboBox.SelectedIndex = 1;
            return(comboBox);
        }
示例#14
0
 public ComboBoxBinder(string value, IEnumerable <string> hints, ComboBoxStyle style)
 {
     if (style == ComboBoxStyle.DropDownList)
     {
         Debug.Assert(Finder.Find(hints, value));
     }
     Init(hints, style, value);
 }
示例#15
0
 /// <summary>
 /// Default ctor, load items from type converted.
 /// </summary>
 public EnumComboBox(ComboBoxStyle dropDownStyle, TypeConverter converter)
 {
     DropDownStyle = dropDownStyle;
     foreach (T value in converter.GetStandardValues())
     {
         AddItem(converter.ConvertToString(value), value);
     }
 }
        public void ComboBoxItemAccessibleObject_FragmentNavigate_Child_ReturnNull(ComboBoxStyle comboBoxStyle)
        {
            using ComboBox comboBox = GetComboBox(comboBoxStyle);
            AccessibleObject childListAccessibleObject = comboBox.ChildListAccessibleObject;
            AccessibleObject comboBoxItem = (AccessibleObject)childListAccessibleObject.FragmentNavigate(Interop.UiaCore.NavigateDirection.FirstChild);

            Assert.Null(comboBoxItem.FragmentNavigate(UiaCore.NavigateDirection.FirstChild));
            Assert.Null(comboBoxItem.FragmentNavigate(UiaCore.NavigateDirection.LastChild));
        }
示例#17
0
        public void ComboBoxAccessibleObject_GetPropertyValue_IfHandleIsCreated_ReturnsExpected(ComboBoxStyle style, bool droppedDown, string expectedAction)
        {
            using ComboBox comboBox = new() { DropDownStyle = style };
            comboBox.CreateControl();
            comboBox.DroppedDown = droppedDown;

            Assert.Equal(expectedAction, comboBox.AccessibilityObject.GetPropertyValue(UiaCore.UIA.LegacyIAccessibleDefaultActionPropertyId));
            Assert.True(comboBox.IsHandleCreated);
        }
        private ComboBox GetComboBoxWithMaxHeight(ComboBoxStyle comboBoxStyle)
        {
            ComboBox comboBox = GetComboBox(comboBoxStyle);

            comboBox.DropDownHeight = 10;
            comboBox.SelectedIndex  = 1;
            comboBox.DroppedDown    = true;
            return(comboBox);
        }
        public void ComboBoxAccessibleObject_DefaultAction_IfHandleIsCreated_ReturnsExpected(ComboBoxStyle style, bool droppedDown, string expectedAction)
        {
            using ComboBox comboBox = new() { DropDownStyle = style };
            comboBox.CreateControl();
            comboBox.DroppedDown = droppedDown;

            Assert.True(comboBox.IsHandleCreated);
            Assert.Equal(expectedAction, comboBox.AccessibilityObject.DefaultAction);
        }
        private ComboBox GetComboBoxWithMaxItems(ComboBoxStyle comboBoxStyle)
        {
            ComboBox comboBox = GetComboBox(comboBoxStyle);

            comboBox.IntegralHeight   = false;
            comboBox.MaxDropDownItems = 1;
            comboBox.SelectedIndex    = 1;
            comboBox.DroppedDown      = true;
            return(comboBox);
        }
示例#21
0
        public static object Show(string Prompt, int WndWidth, ComboBoxStyle style, Font font,object datasource, string displaymember)
        {
            var frm = GetForm(Prompt, WndWidth, style, font);
            (frm.Controls[0] as ComboBox).DataSource = datasource;
            (frm.Controls[0] as ComboBox).DisplayMember = displaymember;
            System.Windows.Forms.DialogResult dr = frm.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
                return frm.Controls[0].Text;

            return string.Empty;
        }
        public void ComboBoxAccessibleObject_FragmentNavigate_FirstChild_NotNull(ComboBoxStyle comboBoxStyle)
        {
            using var control = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };
            var accessibleObject = control.AccessibilityObject;

            UiaCore.IRawElementProviderFragment firstChild = accessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
            Assert.NotNull(firstChild);
        }
示例#23
0
        public void ApplyComboBoxStyle(ComboBoxStyle style)
        {
            if (style.ItemsContainerStyle != null)
            {
                _itemsContainer.ApplyWidgetStyle(style.ItemsContainerStyle);
            }

            _dropDownItemStyle = style.ListItemStyle;

            ApplyButtonStyle(style);
        }
示例#24
0
        public void ComboBoxChildEditUiaProvider_SupportsValuePattern(ComboBoxStyle comboBoxStyle)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            comboBox.CreateControl();
            AccessibleObject accessibleObject = comboBox.ChildEditAccessibleObject;

            Assert.True((bool)accessibleObject.GetPropertyValue(UiaCore.UIA.IsValuePatternAvailablePropertyId));
        }
示例#25
0
        public void DropDownStyleTest()
        {
            ToolStripComboBox ComboBox = null;                       // TODO: Initialize to an appropriate value
            ComboBoxItem      target   = new ComboBoxItem(ComboBox); // TODO: Initialize to an appropriate value
            ComboBoxStyle     expected = new ComboBoxStyle();        // TODO: Initialize to an appropriate value
            ComboBoxStyle     actual;

            target.DropDownStyle = expected;
            actual = target.DropDownStyle;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#26
0
        public ComboBox(ComboBoxStyle style) : base(new Button((ButtonStyle)null))
        {
            HorizontalAlignment = HorizontalAlignment.Left;
            VerticalAlignment   = VerticalAlignment.Top;

            _itemsContainer = new Grid();

            if (style != null)
            {
                ApplyComboBoxStyle(style);
            }
        }
 public ComboBoxCustom(Point point, Size size, Padding padding, ComboBoxStyle boxStyle, FlatStyle flatStyle,
                       string name, float font_size = 12F)
 {
     Location      = point;
     Size          = size;
     Margin        = padding;
     DropDownStyle = boxStyle;
     FlatStyle     = flatStyle;
     ForeColor     = SystemColors.Control;
     TabIndex      = 0;
     TabStop       = false;
     Font          = new Font("Ubuntu Light", font_size, FontStyle.Regular, GraphicsUnit.Point, 204);
 }
        private ComboBox GetComboBox(ComboBoxStyle comboBoxStyle)
        {
            ComboBox comboBox = new ComboBox
            {
                DropDownStyle = comboBoxStyle
            };

            comboBox.Items.Add(1);
            comboBox.Items.Add(2);
            comboBox.Items.Add(3);
            comboBox.CreateControl();
            return(comboBox);
        }
示例#29
0
        private static Form GetForm(string Prompt, int WndWidth, ComboBoxStyle style, Font font)
        {
            Form frm = new System.Windows.Forms.Form();

            frm.AutoSize        = true;
            frm.StartPosition   = System.Windows.Forms.FormStartPosition.CenterParent;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            frm.Height          = 1;
            frm.Width           = 1;
            frm.Text            = Prompt;
            ComboBox cb = new ComboBox();

            cb.DropDownStyle = style;
            if (font != null)
            {
                cb.Font = font;
            }
            cb.Width     = WndWidth;
            cb.KeyPress += KeyPressed;
            frm.Controls.Add(cb);
            System.Windows.Forms.Button okb = new System.Windows.Forms.Button();
            okb.Text = "ОК";
            if (font == null)
            {
                okb.Location = new System.Drawing.Point(25, 24);
            }
            else
            {
                okb.Location = new System.Drawing.Point(25, 24 + (int)(font.Size / 2));
            }
            okb.DialogResult = System.Windows.Forms.DialogResult.OK;
            if (font != null)
            {
                okb.Font = font;
            }
            okb.AutoSize = true;
            frm.Controls.Add(okb);
            System.Windows.Forms.Button cancelb = new System.Windows.Forms.Button();
            cancelb.Text         = "Отмена";
            cancelb.Location     = new System.Drawing.Point(100, 24 + (int)(font.Size / 2));
            cancelb.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            cancelb.AutoSize     = true;
            if (font != null)
            {
                cancelb.Font = font;
            }
            frm.Controls.Add(cancelb);

            return(frm);
        }
示例#30
0
        public void DropDownButtonUiaProvider_FragmentNavigate_PreviousSibling_ReturnsExpected_IfHandleIsNotCreated(
            ComboBoxStyle comboBoxStyle)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            AccessibleObject previousItem = GetComboBoxAccessibleObject(comboBox).DropDownButtonUiaProvider
                                            .FragmentNavigate(UiaCore.NavigateDirection.PreviousSibling) as AccessibleObject;

            Assert.Null(previousItem);
            Assert.False(comboBox.IsHandleCreated);
        }
示例#31
0
        public ComboBox(ComboBoxStyle style) : base(style)
        {
            HorizontalAlignment = HorizontalAlignment.Left;
            VerticalAlignment   = VerticalAlignment.Top;

            _itemsContainer = new Grid();

            if (style != null)
            {
                ApplyComboBoxStyle(style);
            }

            _items.CollectionChanged += ItemsOnCollectionChanged;
        }
示例#32
0
        public void DropDownButtonUiaProvider_Name_ReturnsExpected(ComboBoxStyle comboBoxStyle)
        {
            using ComboBox comboBox = new ComboBox
                  {
                      DropDownStyle = comboBoxStyle
                  };

            Assert.Equal(SR.ComboboxDropDownButtonOpenName, GetComboBoxAccessibleObject(comboBox).DropDownButtonUiaProvider.Name);

            // Open the dropdown list
            comboBox.DroppedDown = true;

            Assert.Equal(SR.ComboboxDropDownButtonCloseName, GetComboBoxAccessibleObject(comboBox).DropDownButtonUiaProvider.Name);
        }
示例#33
0
        //=====================================================================
        /// <summary>
        /// Constructor
        /// </summary>
        protected BaseComboBox()
        {
            maxDropDownItems = 8;
            dropDownStyle = ComboBoxStyle.DropDown;
            dropDownBackColor = SystemColors.Control;
            autoCompleteText = String.Empty;
            autoCompleteEnabled = true;
            simpleHeight = 48;
            hTheme = IntPtr.Zero;
            themeState = UnsafeNativeMethods.ComboBoxNormal;

            dropDownFont = new Font(Control.DefaultFont, Control.DefaultFont.Style);

            this.SuspendLayout();

            txtValue = new BaseComboBox.ComboTextBox(this);
            txtValue.AutoSize = false;
            txtValue.Location = new System.Drawing.Point(1, 1);
            txtValue.Size = new System.Drawing.Size(128, 15);
            txtValue.TabIndex = 0;

            this.Controls.Add(this.txtValue);
            this.Size = new System.Drawing.Size(150, 23);
            this.ResumeLayout(false);

            txtValue.TextChanged += txtValue_TextChanged;
            txtValue.GotFocus += txtValue_GotFocus;
            txtValue.LostFocus += txtValue_LostFocus;
            txtValue.Click += txtValue_Click;
            txtValue.DoubleClick += txtValue_DoubleClick;
            txtValue.MouseUp += txtValue_MouseUp;
            txtValue.MouseDown += txtValue_MouseDown;
            txtValue.KeyDown += txtValue_KeyDown;
            txtValue.KeyPress += txtValue_KeyPress;
            txtValue.KeyUp += txtValue_KeyUp;
            txtValue.PreviewKeyDown += txtValue_PreviewKeyDown;

            base.ForeColor = txtValue.ForeColor;
            base.BackColor = txtValue.BackColor;
        }
示例#34
0
        public ComboBoxElement(BindingList<object> list, ComboBoxStyle style)
        {
            var combo = new ComboBox();
            combo.DataSource = list;
            combo.DropDownStyle = style;

            // BindingList<T>.ResetBindings() when set as ComboBox.DataSource will clear the SelectedValue (and subsequently Text) of the combo
            // therefore, hook ListChanged, cache the current SelectedValue/Text and on SelectedValueChanged, check if there's a cached value and set it.
            // Also, if SetValues() is called before the list data exists and we have DropDownList, we'll need to cache the value for when the list updates.
            list.ListChanged += (s, e) =>
            {
                if (_cache == null)
                    _cache = style == ComboBoxStyle.DropDownList ? combo.SelectedItem : combo.Text;
            };
            combo.SelectedValueChanged += (s, e) =>
            {
                if (_cache != null)
                {
                    var value = _cache;
                    _cache = null;
                    if (style == ComboBoxStyle.DropDownList)
                        combo.SelectedItem = value;
                    else
                        combo.Text = value.ToString();
                }
            };

            // TextChanged handles list selection and user input
            combo.TextChanged += (sender, e) =>{ OnChanged(); };

            // SelectedIndexChanged handles DropDownList selection
            combo.SelectedIndexChanged += (sender, e) => { OnChanged(); };

            // Detect Enter key and trigger search
            combo.KeyDown += (sender, e) => { if (e.KeyCode == Keys.Enter) OnSearch(); };
            Element = combo;

            dbqf.WinForms.Extensions.ComboBoxExtension.AdjustWidthOnDropDown(combo);
        }
示例#35
0
        private static Form GetForm(string Prompt, int WndWidth,ComboBoxStyle style, Font font)
        {
            Form frm = new System.Windows.Forms.Form();
            frm.AutoSize = true;
            frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            frm.Height = 1;
            frm.Width = 1;
            frm.Text = Prompt;
            ComboBox cb = new ComboBox();
            cb.DropDownStyle = style;
            if (font != null)
                cb.Font = font;
            cb.Width = WndWidth;
            cb.KeyPress += KeyPressed;
            frm.Controls.Add(cb);
            System.Windows.Forms.Button okb = new System.Windows.Forms.Button();
            okb.Text = "ОК";
            if (font == null)
                okb.Location = new System.Drawing.Point(25, 24);
            else
                okb.Location = new System.Drawing.Point(25, 24 + (int)(font.Size / 2));
            okb.DialogResult = System.Windows.Forms.DialogResult.OK;
            if (font != null)
                okb.Font = font;
            okb.AutoSize = true;
            frm.Controls.Add(okb);
            System.Windows.Forms.Button cancelb = new System.Windows.Forms.Button();
            cancelb.Text = "Отмена";
            cancelb.Location = new System.Drawing.Point(100, 24 + (int)(font.Size / 2));
            cancelb.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            cancelb.AutoSize = true;
            if (font != null)
                cancelb.Font = font;
            frm.Controls.Add(cancelb);

            return frm;
        }
示例#36
0
        internal void Init(AdminArg arg)
        {
            // 先清空
            this.dataBox.Text = null;
            this.dataBox.Items.Clear();
            dataBox.SuspendLayout();
            switch(arg.Style)
            {
                case BoxStyle.Text:
                    {
                        this.Style = ComboBoxStyle.Simple;
                    }
                    break;
                case BoxStyle.Combox:
                    {// 下拉菜单
                        this.Style = ComboBoxStyle.DropDown;
                        if(arg.Items.Count > 0)
                        {
                            foreach (var item in arg.Items)
                            {
                                dataBox.Items.Add(item);
                            }
                            this.dataBox.SelectedIndex = 0;
                        }
                    }
                    break;
                case BoxStyle.Option:
                    {
                        this.Style = ComboBoxStyle.DropDownList;
                        if(arg.Options != null && arg.Options.Count > 0)
                        {
                            foreach (var option in arg.Options)
                            {
                                dataBox.Items.Add(option);
                            }
                            this.dataBox.SelectedIndex = 0;
                        }
                    }
                    break;
            }

            this.Tag = arg;
            this.ArgName = arg.Show;
            this.ArgData = arg.Data;
            dataBox.ResumeLayout();
        }
示例#37
0
		public DGCBColumn(ComboBoxStyle cbs) 
		{ 
			_cb.Visible = false; 
			_cb.DropDownStyle = cbs; 
		} 
 public void setComboType(ComboBoxStyle combSty)
 {
     cboSelectTemplate.DropDownStyle = combSty;
 }
示例#39
0
 private void AddToolBarComboBoxButton(Hashtable table, System.Type commandGroup, int commandID, string helpText, int width, ComboBoxStyle style, object[] items)
 {
     this.AddToolBarComboBoxButton(table, commandGroup, commandID, 0, helpText, width, style, items, null);
 }
示例#40
0
 private void AddToolBarComboBoxButton(Hashtable table, System.Type commandGroup, int commandID, int fillCommandID, string helpText, int width, ComboBoxStyle style, object[] items, string initialText)
 {
     ComboBoxToolBarButton button = new ComboBoxToolBarButton();
     button.DropDownStyle = style;
     button.ComboBoxItems = items;
     button.ToolTipText = helpText;
     button.Text = new string('_', width);
     button.InitialText = initialText;
     button.ImageIndex = 0;
     table[commandID] = button;
     this.cm.AddCommand(button, commandGroup, commandID, fillCommandID);
 }
示例#41
0
 protected override void OnEnabledChanged(EventArgs e)
 {
     base.OnEnabledChanged(e);
     this.updatingStyle = true;
     if (this.Enabled) this.DropDownStyle = this.prevStyle;
     else
     {
         this.prevStyle = this.DropDownStyle;
         this.DropDownStyle = ComboBoxStyle.DropDownList;
     }
     this.updatingStyle = false;
 }
示例#42
0
 protected override void OnDropDownStyleChanged(EventArgs e)
 {
     base.OnDropDownStyleChanged(e);
     if (!this.updatingStyle) this.prevStyle = this.DropDownStyle;
 }
        /// <summary>
        /// MustRenderVisibleControl
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        private bool MustRenderVisibleControl(ComboBoxStyle style)
        {
            if (style == ComboBoxStyle.DropDownList)
                return (true);

            OperatingSystem osInfo = Environment.OSVersion;

            return (osInfo.Platform == PlatformID.Win32Windows ||
                (osInfo.Platform == PlatformID.Win32NT && osInfo.Version.Major < 6));

        }
示例#44
0
 public ComboBoxToolBarButton(string text)
     : base(text)
 {
     this._style = ComboBoxStyle.DropDownList;
     this._dropDownWidth = -1;
 }
示例#45
0
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // ColorDropDown
            // 
            this.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.ResumeLayout(false);

        }