/// <summary> /// Default attached event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="columnHeaders"></param> /// <param name="viewMode"></param> /// <param name="postSetFunc"></param> private static void comboBox_MouseDown(object sender, MouseEventArgs e, string[] columnHeaders, EnhancedComboBoxHelperList.ViewMode viewMode, Action postSetFunc) { if (e.Button == MouseButtons.Right) { ComboBox comboBox = (ComboBox)sender; EnhancedComboBoxHelper.Items[] items = GetItems(comboBox); if (comboBox.Enabled) { comboBox.Focus(); EnhancedComboBoxHelperList enhancedComboBoxHelperList = new EnhancedComboBoxHelperList(comboBox, columnHeaders, items, comboBox.SelectedValue, viewMode, postSetFunc); enhancedComboBoxHelperList.ShowDialog(); } } }
/// <summary> /// Attach the helper to a combobox /// </summary> /// <param name="comboBox"></param> /// <param name="enableAutoCompleteOnEnter"></param> /// <param name="enableDeselectOnEsc"></param> /// <param name="enableShowListOnRightclick"></param> /// <param name="columnHeaders"></param> /// <param name="items"></param> /// <param name="viewMode"></param> /// <param name="postSetFunc"></param> public static void AttachComboBox(ComboBox comboBox, bool enableAutoCompleteOnEnter, bool enableDeselectOnEsc, bool enableShowListOnRightclick, bool enableTooltip, string[] columnHeaders, EnhancedComboBoxHelper.Items[] items, EnhancedComboBoxHelperList.ViewMode viewMode, Action postSetFunc) { CleanLists(); if (comboBox == null) return; UpdateItems(comboBox, items, true); if (enableAutoCompleteOnEnter) SetAutoCompleteOnEnter(comboBox); if (enableDeselectOnEsc) SetDeselectOnEsc(comboBox); if (enableShowListOnRightclick && columnHeaders != null) SetShowListOnRightClick(comboBox, columnHeaders, viewMode, postSetFunc, true); if (enableTooltip) SetToolTipOnMouseOver(comboBox); }
/// <summary> /// Attach the show list on right click event /// </summary> /// <param name="comboBox"></param> /// <param name="columnHeaders"></param> /// <param name="viewMode"></param> /// <param name="postSetFunc"></param> /// <param name="drawInfoicon"></param> private static void SetShowListOnRightClick(ComboBox comboBox, string[] columnHeaders, EnhancedComboBoxHelperList.ViewMode viewMode, Action postSetFunc, bool drawInfoicon) { if (comboBox != null) { if (!_attached_MouseDown.ContainsKey(comboBox)) { _attached_MouseDown.Add(comboBox, new MouseEventHandler((sender, e) => comboBox_MouseDown(sender, e, columnHeaders, viewMode, postSetFunc))); if (drawInfoicon && comboBox.Parent != null) comboBox.Parent.Paint += new PaintEventHandler((sender, e) => comboBox_PaintInfoicon(sender, e, comboBox)); } else { comboBox.MouseDown -= _attached_MouseDown[comboBox]; _attached_MouseDown[comboBox] = new MouseEventHandler((sender, e) => comboBox_MouseDown(sender, e, columnHeaders, viewMode, postSetFunc)); } comboBox.MouseDown += _attached_MouseDown[comboBox]; } }
/// <summary> /// Attach the helper to a combobox, set the view mode, autocomplete enabled, deselect enabled, showlist enabled, tooltip enabled /// </summary> /// <param name="comboBox"></param> /// <param name="columnHeaders"></param> /// <param name="items"></param> /// <param name="viewMode"></param> public static void AttachComboBox(ComboBox comboBox, string[] columnHeaders, EnhancedComboBoxHelper.Items[] items, EnhancedComboBoxHelperList.ViewMode viewMode) { AttachComboBox(comboBox, true, true, true, true, columnHeaders, items, viewMode, null); }
/// <summary> /// Attach the helper to a combobox, set the view mode, autocomplete enabled, deselect enabled, showlist enabled /// </summary> /// <param name="comboBox"></param> /// <param name="columnHeaders"></param> /// <param name="items"></param> /// <param name="viewMode"></param> /// <param name="postSetFunc"></param> public static void AttachComboBox(ComboBox comboBox, string[] columnHeaders, EnhancedComboBoxHelper.Items[] items, EnhancedComboBoxHelperList.ViewMode viewMode, Action postSetFunc) { AttachComboBox(comboBox, true, true, true, true, columnHeaders, items, viewMode, postSetFunc); }