Beispiel #1
0
        /// <summary>
        /// 向下拉框添加具有指定文本,值,名称的Item
        /// </summary>
        public void Add(String text, Object value = null, String name = null)
        {
            ComboboxToolStripItem item = new ComboboxToolStripItem();

            item.Padding = new Padding();
            item.Text    = text;

            item.Size            = new Size(this._toolStripDropDown.Width, this.ItemHeight);
            item.AutoSize        = false;
            item.Value           = value;
            item.Name            = name ?? Guid.NewGuid().ToString("N");
            item.Font            = this.ItemFont;
            item.Size            = new Size(this._toolStripDropDown.Width, this.ItemHeight);
            item.Index           = this._toolStripDropDown.Items.Count - 1;
            item.TextAlignFormat = this.TextAlignFormat;
            item.Click          += (s, e) =>
            {
                this.OnSelectItemChanged(this, item);
            };
            this._toolStripDropDown.Items.Add(item);
        }
Beispiel #2
0
 protected virtual void OnSelectItemChanged(Object sender, ComboboxToolStripItem item)
 {
     this.SelectedItem = item;
     this.Text         = this.SelectedItem.Text;
     this.SelectItemChanged?.Invoke(sender, item);
 }