void OnSelectedIndexChanged(object sender, EventArgs e) { if (!this.addingFile) { ComboRecentItem item = this._box.SelectedItem as ComboRecentItem; if (item != null) { this._values.OnRecentFileSelected(item.Value); } } }
private void OnRecentItemsChanged(object sender, EventArgs e) { // Synchronize menu items. this.addingFile = true; try { // Add most recent files first. string[] recentValues = this._values.GetLatestValues(); // Synchronize combo-box items this._box.Items.Clear(); for (int i = recentValues.Length - 1; i >= 0; i--) { string item = recentValues[i]; this._box.Items.Add(new ComboRecentItem(item)); } if (this._box.Items.Count > 0 && this.SelectFirstItemByDefault) { this._box.SelectedIndex = 0; } // sync autocompletion list this._box.AutoCompleteCustomSource.Clear(); for (int i = 0; i < this._box.Items.Count; i++) { ComboRecentItem item = (ComboRecentItem)this._box.Items[i]; this._box.AutoCompleteCustomSource.Add(item.ToString()); } } finally { this.addingFile = false; } }