public DropDown(IList items, ControlStyle dropDownStyle, ControlStyle buttonStyle) : base()
        {
            if (dropDownStyle == null || buttonStyle == null)
            {
                throw new NotSupportedException("You must provide a style for this DropDown.");
            }
            Style           = dropDownStyle;
            _dropDownButton = new Button(buttonStyle);
            _dropDownButton.AnchorTo(this, Anchoring.PositionType.Outside_Left_Top, 0, 0, Anchoring.AnchorType.Bounds);

            Items = new ObservableCollection <string>();
            Items = (ObservableCollection <string>)items;

            _render = new DropDownRenderer(this);
        }
Beispiel #2
0
            public DropDown(KAbstractComboBox owner, Control control)
            {
                this._owner = owner;

                KVisualStyle <COMBOBOXPARTS, State> .Part style = owner._style[COMBOBOXPARTS.CP_BORDER];
                Renderer = new DropDownRenderer(style);
                using (Graphics graphics = CreateGraphics())
                {
                    Padding = style?.GetMargins(graphics, State.Pressed) ?? new Padding();
                }

                Margin            = new Padding(0);
                AutoSize          = true;
                DropShadowEnabled = false;
                AutoClose         = false;

                // Add a host for the control
                ToolStripControlHost host = new ToolStripControlHost(control);

                host.Padding  = new Padding(0);
                host.Margin   = new Padding(0);
                host.AutoSize = true;
                Items.Add(host);
            }