Esempio n. 1
0
        /// <summary>
        /// キーバリュー形式のアイテムを追加する
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void AddItem(TKey key, TValue value, bool autoCalcWidth = true)
        {
            if (!this.container.ContainsKey(key))
            {
                var item = new ComboTextHolder(key, value);
                if (OnGetViewText != null)
                {
                    item.OnGetViewText += this.OnGetViewText;
                }
                this.comboBox.Items.Add(item);
                this.container.Add(key, value);

                if (autoCalcWidth)
                {
                    RecalcComboDropdownWidth();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// コンボボックスの内容をリフレッシュする
        /// </summary>
        public void Refresh()
        {
            //コンボボックスのテキストは動的に変化しない・・・.NETのバグらしい・・・

            //今選択されているインデックス
            int index = this.comboBox.SelectedIndex;

            this.comboBox.Items.Clear();

            foreach (var key in this.container.Keys)
            {
                var item = new ComboTextHolder(key, this.container[key]);
                if (OnGetViewText != null)
                {
                    item.OnGetViewText += this.OnGetViewText;
                }
                this.comboBox.Items.Add(item);
            }
            RecalcComboDropdownWidth();
            this.SelectIndex(index);
        }