/// <summary> /// Closes the dropdown portion and enacts any changes according to the specified boolean parameter. /// NOTE: even though the caller might ask for changes to be enacted, this doesn't necessarily mean /// that any changes have occurred as such. Caller should check the ValueChanged property of the /// CheckedComboBox (after the dropdown has closed) to determine any actual value changes. /// </summary> /// <param name="enactChanges"></param> public void CloseDropdown(bool enactChanges) { if (dropdownClosed) { return; } Debug.WriteLine("CloseDropdown"); // Perform the actual selection and display of checked items. if (enactChanges) { ccbParent.SelectedIndex = -1; // Set the text portion equal to the string comprising all checked items (if any, otherwise empty!). ccbParent.Text = GetCheckedItemsStringValue(); } else { // Caller cancelled selection - need to restore the checked items to their original state. for (int i = 0; i < cclb.Items.Count; i++) { cclb.SetItemChecked(i, checkedStateArr[i]); } } // From now on the dropdown is considered closed. We set the flag here to prevent OnDeactivate() calling // this method once again after hiding this window. dropdownClosed = true; // Set the focus to our parent CheckedComboBox and hide the dropdown check list. //ccbParent.Focus(); //this.Hide(); //cclb.Focus(); ccbParent.Hide(); cclb.Hide(); // Notify CheckedComboBox that its dropdown is closed. (NOTE: it does not matter which parameters we pass to // OnDropDownClosed() as long as the argument is CCBoxEventArgs so that the method knows the notification has // come from our code and not from the framework). ccbParent.OnDropDownClosed(new CCBoxEventArgs(null, false)); }