1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Jordi Mas i Hernandez, jordi@ximian.com
31 using System.Collections;
32 using System.ComponentModel;
33 using System.Reflection;
34 using System.ComponentModel.Design;
35 using System.ComponentModel.Design.Serialization;
36 using System.Runtime.InteropServices;
39 namespace System.Windows.Forms
42 [DefaultProperty("Items")]
43 [DefaultEvent("SelectedIndexChanged")]
44 [Designer ("System.Windows.Forms.Design.ComboBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
45 public class ComboBox : ListControl
47 private DrawMode draw_mode;
48 private ComboBoxStyle dropdown_style;
49 private int dropdown_width;
50 private const int preferred_height = 20;
51 private int selected_index;
52 private object selected_item;
53 internal ObjectCollection items = null;
54 private bool suspend_ctrlupdate;
55 private int maxdrop_items;
56 private bool integral_height;
58 internal ComboBoxInfo combobox_info;
59 private readonly int def_button_width = 16;
61 private int max_length;
62 private ComboListBox listbox_ctrl;
63 private TextBox textbox_ctrl;
64 private bool process_textchanged_event;
67 public class ChildAccessibleObject : AccessibleObject {
68 private ComboBox owner;
69 private IntPtr handle;
71 public ChildAccessibleObject (ComboBox owner, IntPtr handle) {
76 public override string Name {
85 internal class ComboBoxInfo
87 internal int item_height; /* Item's height */
88 internal Rectangle textarea; /* Rectangle of the editable text area */
89 internal Rectangle textarea_drawable; /* Rectangle of the editable text area - decorations - button if present*/
90 internal Rectangle button_rect;
91 internal bool show_button; /* Is the DropDown button shown? */
92 internal ButtonState button_status; /* Drop button status */
93 internal int original_height; /* Control's height is recalculated for not Simple Styles */
94 internal Rectangle listbox_area; /* ListBox area in Simple combox, not used in the rest */
95 internal bool droppeddown; /* Is the associated ListBox dropped down? */
96 internal int combosimple_height; /* Simple default height */
98 public ComboBoxInfo ()
100 button_status = ButtonState.Normal;
104 original_height = -1;
105 combosimple_height = 150;
109 internal class ComboBoxItem
112 internal int ItemHeight; /* Only used for OwnerDrawVariable */
114 public ComboBoxItem (int index)
123 items = new ObjectCollection (this);
126 combobox_info = new ComboBoxInfo ();
127 combobox_info.item_height = FontHeight + 2;
128 dropdown_style = (ComboBoxStyle)(-1);
129 DropDownStyle = ComboBoxStyle.DropDown;
130 BackColor = ThemeEngine.Current.ColorWindow;
131 draw_mode = DrawMode.Normal;
133 selected_item = null;
135 suspend_ctrlupdate = false;
139 integral_height = true;
140 process_textchanged_event = true;
144 MouseDown += new MouseEventHandler (OnMouseDownCB);
145 MouseUp += new MouseEventHandler (OnMouseUpCB);
146 MouseMove += new MouseEventHandler (OnMouseMoveCB);
147 KeyDown +=new KeyEventHandler(OnKeyDownCB);
153 [EditorBrowsable (EditorBrowsableState.Never)]
154 public new event EventHandler BackgroundImageChanged;
156 public event DrawItemEventHandler DrawItem;
157 public event EventHandler DropDown;
158 public event EventHandler DropDownStyleChanged;
159 public event MeasureItemEventHandler MeasureItem;
162 [EditorBrowsable (EditorBrowsableState.Never)]
163 public new event PaintEventHandler Paint;
165 public event EventHandler SelectedIndexChanged;
166 public event EventHandler SelectionChangeCommitted;
169 #region Public Properties
170 public override Color BackColor {
171 get { return base.BackColor; }
173 if (base.BackColor == value)
176 base.BackColor = value;
182 [EditorBrowsable (EditorBrowsableState.Never)]
183 public override Image BackgroundImage {
184 get { return base.BackgroundImage; }
186 if (base.BackgroundImage == value)
189 base.BackgroundImage = value;
191 if (BackgroundImageChanged != null)
192 BackgroundImageChanged (this, EventArgs.Empty);
198 protected override CreateParams CreateParams {
199 get { return base.CreateParams;}
202 protected override Size DefaultSize {
203 get { return new Size (121, PreferredHeight); }
206 [RefreshProperties(RefreshProperties.Repaint)]
207 [DefaultValue (DrawMode.Normal)]
208 public DrawMode DrawMode {
209 get { return draw_mode; }
212 if (!Enum.IsDefined (typeof (DrawMode), value))
213 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for DrawMode", value));
215 if (draw_mode == value)
223 [DefaultValue (ComboBoxStyle.DropDown)]
224 [RefreshProperties(RefreshProperties.Repaint)]
225 public ComboBoxStyle DropDownStyle {
226 get { return dropdown_style; }
230 if (!Enum.IsDefined (typeof (ComboBoxStyle), value))
231 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for ComboBoxStyle", value));
233 if (dropdown_style == value)
236 if (dropdown_style == ComboBoxStyle.Simple) {
237 if (listbox_ctrl != null) {
238 Controls.RemoveImplicit (listbox_ctrl);
239 listbox_ctrl.Dispose ();
241 Height = combobox_info.original_height;
245 if (dropdown_style != ComboBoxStyle.DropDownList && value == ComboBoxStyle.DropDownList) {
246 if (textbox_ctrl != null) {
247 Controls.RemoveImplicit (textbox_ctrl);
248 textbox_ctrl.Dispose ();
253 dropdown_style = value;
255 if (dropdown_style == ComboBoxStyle.Simple) {
256 CBoxInfo.show_button = false;
257 combobox_info.original_height = Height;
258 Height = combobox_info.combosimple_height;
260 CreateComboListBox ();
262 if (IsHandleCreated == true) {
263 Controls.AddImplicit (listbox_ctrl);
267 CBoxInfo.show_button = true;
268 CBoxInfo.button_status = ButtonState.Normal;
271 if (dropdown_style != ComboBoxStyle.DropDownList && textbox_ctrl == null) {
272 textbox_ctrl = new FixedSizeTextBox ();
273 textbox_ctrl.BorderStyle = BorderStyle.None;
274 textbox_ctrl.TextChanged += new EventHandler (OnTextChangedEdit);
275 textbox_ctrl.KeyPress += new KeyPressEventHandler(textbox_ctrl_KeyPress);
276 textbox_ctrl.KeyDown += new KeyEventHandler (OnKeyDownCB);
277 textbox_ctrl.GotFocus += new EventHandler(textbox_ctrl_GotFocus);
278 textbox_ctrl.LostFocus += new EventHandler(textbox_ctrl_LostFocus);
280 if (IsHandleCreated == true) {
281 Controls.AddImplicit (textbox_ctrl);
285 if (DropDownStyleChanged != null)
286 DropDownStyleChanged (this, EventArgs.Empty);
293 public int DropDownWidth {
295 if (dropdown_width == -1)
298 return dropdown_width;
301 if (dropdown_width == value)
305 throw new ArgumentException ("The DropDownWidth value is less than one");
307 dropdown_width = value;
312 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
313 public bool DroppedDown {
315 if (dropdown_style == ComboBoxStyle.Simple)
318 return CBoxInfo.droppeddown;
321 if (dropdown_style == ComboBoxStyle.Simple)
329 listbox_ctrl.Hide ();
332 if (DropDown != null)
333 DropDown (this, EventArgs.Empty);
337 public override bool Focused {
338 get { return base.Focused; }
341 public override Color ForeColor {
342 get { return base.ForeColor; }
344 if (base.ForeColor == value)
347 base.ForeColor = value;
352 [DefaultValue (true)]
354 public bool IntegralHeight {
355 get { return integral_height; }
357 if (integral_height == value)
360 integral_height = value;
366 public int ItemHeight {
367 get { return combobox_info.item_height; }
370 throw new ArgumentException ("The item height value is less than zero");
372 combobox_info.item_height = value;
378 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
380 [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
381 public ComboBox.ObjectCollection Items {
382 get { return items; }
387 public int MaxDropDownItems {
388 get { return maxdrop_items; }
390 if (maxdrop_items == value)
393 maxdrop_items = value;
399 public int MaxLength {
400 get { return max_length; }
402 if (max_length == value)
407 if (dropdown_style != ComboBoxStyle.DropDownList) {
413 textbox_ctrl.MaxLength = value;
418 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
420 public int PreferredHeight {
421 get { return preferred_height; }
425 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
426 public override int SelectedIndex {
427 get { return selected_index; }
429 if (value <= -2 || value >= Items.Count)
430 throw new ArgumentOutOfRangeException ("Index of out range");
432 if (selected_index == value)
435 selected_index = value;
437 if (dropdown_style != ComboBoxStyle.DropDownList) {
438 SetControlText (GetItemText (Items[selected_index]));
441 OnSelectedIndexChanged (new EventArgs ());
442 OnSelectedValueChanged (new EventArgs ());
443 OnSelectedItemChanged (new EventArgs ());
449 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
451 public object SelectedItem {
453 if (selected_index !=-1 && Items !=null && Items.Count > 0)
454 return Items[selected_index];
459 int index = Items.IndexOf (value);
464 if (selected_index == index)
467 selected_index = index;
469 if (dropdown_style != ComboBoxStyle.DropDownList) {
470 SetControlText (GetItemText (Items[selected_index]));
473 OnSelectedItemChanged (new EventArgs ());
479 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
480 public string SelectedText {
482 if (dropdown_style == ComboBoxStyle.DropDownList)
485 return textbox_ctrl.SelectedText;
488 if (dropdown_style == ComboBoxStyle.DropDownList) {
492 textbox_ctrl.SelectedText = value;
497 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
498 public int SelectionLength {
500 if (dropdown_style == ComboBoxStyle.DropDownList)
503 return textbox_ctrl.SelectionLength;
506 if (dropdown_style == ComboBoxStyle.DropDownList)
509 if (textbox_ctrl.SelectionLength == value)
512 textbox_ctrl.SelectionLength = value;
517 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
518 public int SelectionStart {
520 if (dropdown_style == ComboBoxStyle.DropDownList)
523 return textbox_ctrl.SelectionStart;
526 if (dropdown_style == ComboBoxStyle.DropDownList)
529 if (textbox_ctrl.SelectionStart == value)
532 textbox_ctrl.SelectionStart = value;
536 [DefaultValue (false)]
538 get { return sorted; }
550 public override string Text {
552 if (dropdown_style != ComboBoxStyle.DropDownList) {
553 if (textbox_ctrl != null) {
554 return textbox_ctrl.Text;
558 if (SelectedItem != null) {
559 return GetItemText (SelectedItem);
570 int index = FindString (value);
573 SelectedIndex = index;
577 if (dropdown_style != ComboBoxStyle.DropDownList) {
578 textbox_ctrl.Text = GetItemText (value);
583 #endregion Public Properties
585 #region Private Properties
586 internal ComboBoxInfo CBoxInfo {
587 get { return combobox_info; }
590 #endregion Private Properties
592 #region Public Methods
593 protected virtual void AddItemsCore (object[] value)
598 public void BeginUpdate ()
600 suspend_ctrlupdate = true;
603 protected override void Dispose (bool disposing)
605 if (disposing == true) {
606 if (listbox_ctrl != null) {
607 listbox_ctrl.Dispose ();
608 Controls.RemoveImplicit (listbox_ctrl);
612 if (textbox_ctrl != null) {
613 Controls.RemoveImplicit (textbox_ctrl);
614 textbox_ctrl.Dispose ();
619 base.Dispose (disposing);
622 public void EndUpdate ()
624 suspend_ctrlupdate = false;
628 public int FindString (string s)
630 return FindString (s, -1);
633 public int FindString (string s, int startIndex)
635 if (Items.Count == 0)
636 return -1; // No exception throwing if empty
638 if (startIndex < -1 || startIndex >= Items.Count - 1)
639 throw new ArgumentOutOfRangeException ("Index of out range");
642 for (int i = startIndex; i < Items.Count; i++) {
643 if ((GetItemText (Items[i])).StartsWith (s))
650 public int FindStringExact (string s)
652 return FindStringExact (s, -1);
655 public int FindStringExact (string s, int startIndex)
657 if (Items.Count == 0)
658 return -1; // No exception throwing if empty
660 if (startIndex < -1 || startIndex >= Items.Count - 1)
661 throw new ArgumentOutOfRangeException ("Index of out range");
664 for (int i = startIndex; i < Items.Count; i++) {
665 if ((GetItemText (Items[i])).Equals (s))
672 public int GetItemHeight (int index)
674 if (DrawMode == DrawMode.OwnerDrawVariable && IsHandleCreated == true) {
676 if (index < 0 || index >= Items.Count )
677 throw new ArgumentOutOfRangeException ("The item height value is less than zero");
679 if ((Items.GetComboBoxItem (index)).ItemHeight != -1) {
680 return (Items.GetComboBoxItem (index)).ItemHeight;
683 MeasureItemEventArgs args = new MeasureItemEventArgs (DeviceContext, index, ItemHeight);
684 OnMeasureItem (args);
685 (Items.GetComboBoxItem (index)).ItemHeight = args.ItemHeight;
686 return args.ItemHeight;
692 protected override bool IsInputKey (Keys keyData)
706 protected override void OnBackColorChanged (EventArgs e)
708 base.OnBackColorChanged (e);
711 protected override void OnDataSourceChanged (EventArgs e)
713 base.OnDataSourceChanged (e);
714 BindDataItems (items);
716 if (DataSource == null || DataManager == null) {
720 SelectedIndex = DataManager.Position;
724 protected override void OnDisplayMemberChanged (EventArgs e)
726 base.OnDisplayMemberChanged (e);
728 if (DataManager == null || !IsHandleCreated)
731 BindDataItems (items);
732 SelectedIndex = DataManager.Position;
735 protected virtual void OnDrawItem (DrawItemEventArgs e)
737 if (DrawItem != null && (DrawMode == DrawMode.OwnerDrawFixed || DrawMode == DrawMode.OwnerDrawVariable)) {
742 ThemeEngine.Current.DrawComboBoxItem (this, e);
745 protected virtual void OnDropDown (EventArgs e)
747 if (DropDown != null)
751 protected virtual void OnDropDownStyleChanged (EventArgs e)
753 if (DropDownStyleChanged != null)
754 DropDownStyleChanged (this, e);
757 protected override void OnFontChanged (EventArgs e)
759 base.OnFontChanged (e);
761 if (textbox_ctrl != null) {
762 textbox_ctrl.Font = Font;
765 combobox_info.item_height = FontHeight + 2;
769 protected override void OnForeColorChanged (EventArgs e)
771 base.OnForeColorChanged (e);
774 [EditorBrowsable(EditorBrowsableState.Advanced)]
775 protected override void OnGotFocus (EventArgs e) {
780 [EditorBrowsable(EditorBrowsableState.Advanced)]
781 protected override void OnLostFocus (EventArgs e) {
786 protected override void OnHandleCreated (EventArgs e)
788 base.OnHandleCreated (e);
790 if (listbox_ctrl != null) {
791 Controls.AddImplicit (listbox_ctrl);
793 if (dropdown_style == ComboBoxStyle.Simple)
794 Height = combobox_info.combosimple_height;
798 if (textbox_ctrl != null) {
799 Controls.AddImplicit (textbox_ctrl);
805 protected override void OnHandleDestroyed (EventArgs e)
807 base.OnHandleDestroyed (e);
810 protected override void OnKeyPress (KeyPressEventArgs e)
815 protected virtual void OnMeasureItem (MeasureItemEventArgs e)
817 if (MeasureItem != null)
818 MeasureItem (this, e);
821 protected override void OnParentBackColorChanged (EventArgs e)
823 base.OnParentBackColorChanged (e);
826 protected override void OnResize (EventArgs e)
829 AdjustHeightForDropDown ();
831 if (listbox_ctrl != null)
832 listbox_ctrl.CalcListBoxArea ();
837 protected override void OnSelectedIndexChanged (EventArgs e)
839 base.OnSelectedIndexChanged (e);
841 if (SelectedIndexChanged != null)
842 SelectedIndexChanged (this, e);
845 protected virtual void OnSelectedItemChanged (EventArgs e)
850 protected override void OnSelectedValueChanged (EventArgs e)
852 base.OnSelectedValueChanged (e);
855 protected virtual void OnSelectionChangeCommitted (EventArgs e)
857 if (SelectionChangeCommitted != null)
858 SelectionChangeCommitted (this, e);
861 protected override void RefreshItem (int index)
863 if (index < 0 || index >= Items.Count)
864 throw new ArgumentOutOfRangeException ("Index of out range");
866 if (draw_mode == DrawMode.OwnerDrawVariable) {
867 (Items.GetComboBoxItem (index)).ItemHeight = -1;
871 public void Select (int start, int lenght)
874 throw new ArgumentException ("Start cannot be less than zero");
877 throw new ArgumentException ("Start cannot be less than zero");
879 if (dropdown_style == ComboBoxStyle.DropDownList)
882 textbox_ctrl.Select (start, lenght);
885 public void SelectAll ()
887 if (dropdown_style == ComboBoxStyle.DropDownList)
890 textbox_ctrl.SelectAll ();
893 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
895 base.SetBoundsCore (x, y, width, height, specified);
898 protected override void SetItemCore (int index, object value)
900 if (index < 0 || index >= Items.Count)
903 Items[index] = value;
906 protected override void SetItemsCore (IList value)
908 Items.AddRange (value);
911 public override string ToString ()
913 return base.ToString () + ", Items.Count:" + Items.Count;
916 protected override void WndProc (ref Message m)
919 switch ((Msg) m.Msg) {
922 PaintEventArgs paint_event;
923 paint_event = XplatUI.PaintEventStart (Handle, true);
924 OnPaintCB (paint_event);
925 XplatUI.PaintEventEnd (Handle, true);
929 case Msg.WM_ERASEBKGND:
930 m.Result = (IntPtr) 1;
937 base.WndProc (ref m);
941 #endregion Public Methods
943 #region Private Methods
945 private void AdjustHeightForDropDown ()
947 if (dropdown_style == ComboBoxStyle.Simple)
950 int new_height = combobox_info.item_height + ThemeEngine.Current.DrawComboBoxEditDecorationTop () +
951 ThemeEngine.Current.DrawComboBoxEditDecorationBottom () + 2;
953 if (Height == new_height)
956 combobox_info.original_height = Height;
960 private void textbox_ctrl_KeyPress(object sender, KeyPressEventArgs e)
965 private void textbox_ctrl_GotFocus(object sender, EventArgs e )
970 private void textbox_ctrl_LostFocus(object sender, EventArgs e )
975 // Calcs the text area size
976 internal void CalcTextArea ()
978 combobox_info.textarea = ClientRectangle;
981 combobox_info.textarea.Height = ItemHeight + ThemeEngine.Current.DrawComboBoxEditDecorationTop () +
982 ThemeEngine.Current.DrawComboBoxEditDecorationBottom () + 2;
983 // TODO: Does the +2 change at different font resolutions?
985 /* Edit area - minus decorations (text drawable area) */
986 combobox_info.textarea_drawable = combobox_info.textarea;
987 combobox_info.textarea_drawable.Y += ThemeEngine.Current.DrawComboBoxEditDecorationTop ();
988 combobox_info.textarea_drawable.X += ThemeEngine.Current.DrawComboBoxEditDecorationLeft ();
989 combobox_info.textarea_drawable.Height -= ThemeEngine.Current.DrawComboBoxEditDecorationBottom ();
990 combobox_info.textarea_drawable.Height -= ThemeEngine.Current.DrawComboBoxEditDecorationTop();
991 combobox_info.textarea_drawable.Width -= ThemeEngine.Current.DrawComboBoxEditDecorationRight ();
992 combobox_info.textarea_drawable.Width -= ThemeEngine.Current.DrawComboBoxEditDecorationLeft ();
994 /* Non-drawable area */
995 Region area = new Region (ClientRectangle);
996 area.Exclude (combobox_info.textarea);
997 RectangleF bounds = area.GetBounds (DeviceContext);
998 combobox_info.listbox_area = new Rectangle ((int)bounds.X, (int)bounds.Y,
999 (int)bounds.Width, (int)bounds.Height);
1001 if (CBoxInfo.show_button) {
1002 combobox_info.textarea_drawable.Width -= def_button_width;
1004 combobox_info.button_rect = new Rectangle (combobox_info.textarea_drawable.X + combobox_info.textarea_drawable.Width,
1005 combobox_info.textarea_drawable.Y, def_button_width, combobox_info.textarea_drawable.Height);
1009 if (dropdown_style != ComboBoxStyle.DropDownList) { /* There is an edit control*/
1010 if (textbox_ctrl != null) {
1011 textbox_ctrl.Location = new Point (combobox_info.textarea_drawable.X, combobox_info.textarea_drawable.Y);
1012 textbox_ctrl.Size = new Size (combobox_info.textarea_drawable.Width, combobox_info.textarea_drawable.Height);
1016 if (listbox_ctrl != null && dropdown_style == ComboBoxStyle.Simple) {
1017 listbox_ctrl.Location = new Point (combobox_info.textarea.X, combobox_info.textarea.Y +
1018 combobox_info.textarea.Height);
1019 listbox_ctrl.CalcListBoxArea ();
1025 private void CreateComboListBox ()
1027 listbox_ctrl = new ComboListBox (this);
1030 internal void Draw (Rectangle clip, Graphics dc)
1032 // No edit control, we paint the edit ourselfs
1033 if (dropdown_style == ComboBoxStyle.DropDownList) {
1034 DrawItemState state = DrawItemState.None;
1035 Rectangle item_rect = combobox_info.textarea_drawable;
1036 item_rect.Height = ItemHeight + 2;
1038 if (has_focus == true) {
1039 state = DrawItemState.Selected;
1040 state |= DrawItemState.Focus;
1043 state |= DrawItemState.ComboBoxEdit;
1044 OnDrawItem (new DrawItemEventArgs (dc, Font, item_rect,
1045 selected_index, state, ForeColor, BackColor));
1048 if (DropDownStyle == ComboBoxStyle.Simple && clip.IntersectsWith (combobox_info.listbox_area) == true) {
1049 dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (Parent.BackColor),
1050 combobox_info.listbox_area);
1053 if (CBoxInfo.show_button) {
1054 dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ThemeEngine.Current.ColorControl),
1055 combobox_info.button_rect);
1057 ThemeEngine.Current.CPDrawComboButton (dc,
1058 combobox_info.button_rect, combobox_info.button_status);
1061 ThemeEngine.Current.DrawComboBoxEditDecorations (dc, this, combobox_info.textarea);
1064 internal void DropDownListBox ()
1066 if (DropDownStyle == ComboBoxStyle.Simple)
1069 if (listbox_ctrl == null) {
1070 CreateComboListBox ();
1073 listbox_ctrl.Location = PointToScreen (new Point (combobox_info.textarea.X, combobox_info.textarea.Y +
1074 combobox_info.textarea.Height));
1076 if (listbox_ctrl.ShowWindow () == true) {
1077 CBoxInfo.droppeddown = true;
1080 combobox_info.button_status = ButtonState.Pushed;
1081 if (dropdown_style == ComboBoxStyle.DropDownList) {
1082 Invalidate (combobox_info.textarea_drawable);
1086 internal void DropDownListBoxFinished ()
1088 if (DropDownStyle == ComboBoxStyle.Simple)
1091 combobox_info.button_status = ButtonState.Normal;
1092 Invalidate (combobox_info.button_rect);
1093 CBoxInfo.droppeddown = false;
1097 private int FindStringCaseInsensitive (string search)
1099 if (search.Length == 0) {
1103 for (int i = 0; i < Items.Count; i++)
1105 if (String.Compare (GetItemText (Items[i]), 0, search, 0, search.Length, true) == 0)
1112 private void OnKeyDownCB(object sender, KeyEventArgs e)
1117 SelectedIndex = Math.Max(SelectedIndex-1, 0);
1121 SelectedIndex = Math.Min(SelectedIndex+1, Items.Count-1);
1125 if (listbox_ctrl != null)
1126 SelectedIndex = Math.Max(SelectedIndex- (listbox_ctrl.page_size-1), 0);
1130 if (listbox_ctrl != null)
1131 SelectedIndex = Math.Min(SelectedIndex+(listbox_ctrl.page_size-1), Items.Count-1);
1139 internal virtual void OnMouseDownCB (object sender, MouseEventArgs e)
1141 /* Click On button*/
1144 if (dropdown_style == ComboBoxStyle.DropDownList) {
1145 hit_rect = combobox_info.textarea;
1147 hit_rect = combobox_info.button_rect;
1150 if (hit_rect.Contains (e.X, e.Y)) {
1151 if (clicked == false) {
1155 listbox_ctrl.Hide ();
1156 DropDownListBoxFinished ();
1159 Invalidate (combobox_info.button_rect);
1163 internal virtual void OnMouseMoveCB (object sender, MouseEventArgs e)
1165 /* When there are no items, act as a regular button */
1166 if (clicked == true && Items.Count == 0 &&
1167 combobox_info.button_rect.Contains (e.X, e.Y) == false) {
1168 DropDownListBoxFinished ();
1172 internal virtual void OnMouseUpCB (object sender, MouseEventArgs e)
1174 /* Click on button*/
1175 if (clicked == true && combobox_info.button_rect.Contains (e.X, e.Y)) {
1176 DropDownListBoxFinished ();
1180 private void OnPaintCB (PaintEventArgs pevent)
1182 if (Width <= 0 || Height <= 0 || Visible == false || suspend_ctrlupdate == true)
1185 /* Copies memory drawing buffer to screen*/
1186 Draw (ClientRectangle, pevent.Graphics);
1189 Paint (this, pevent);
1192 private void OnTextChangedEdit (object sender, EventArgs e)
1194 if (process_textchanged_event == false)
1197 int item = FindStringCaseInsensitive (textbox_ctrl.Text);
1202 if (listbox_ctrl != null) {
1203 listbox_ctrl.SetTopItem (item);
1204 listbox_ctrl.SetHighLightedItem (Items[item]);
1208 internal void SetControlText (string s)
1210 process_textchanged_event = false;
1211 textbox_ctrl.Text = s;
1212 process_textchanged_event = true;
1215 private void UpdatedItems ()
1217 if (listbox_ctrl != null) {
1218 listbox_ctrl.UpdateLastVisibleItem ();
1219 listbox_ctrl.CalcListBoxArea ();
1220 listbox_ctrl.Refresh ();
1224 #endregion Private Methods
1228 ComboBox.ObjectCollection
1230 [ListBindableAttribute (false)]
1231 public class ObjectCollection : IList, ICollection, IEnumerable
1234 private ComboBox owner;
1235 internal ArrayList object_items = new ArrayList ();
1236 internal ArrayList combobox_items = new ArrayList ();
1238 public ObjectCollection (ComboBox owner)
1243 #region Public Properties
1244 public virtual int Count {
1245 get { return object_items.Count; }
1248 public virtual bool IsReadOnly {
1249 get { return false; }
1253 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1254 public virtual object this [int index] {
1256 if (index < 0 || index >= Count)
1257 throw new ArgumentOutOfRangeException ("Index of out range");
1259 return object_items[index];
1262 if (index < 0 || index >= Count)
1263 throw new ArgumentOutOfRangeException ("Index of out range");
1265 object_items[index] = value;
1269 bool ICollection.IsSynchronized {
1270 get { return false; }
1273 object ICollection.SyncRoot {
1274 get { return this; }
1277 bool IList.IsFixedSize {
1278 get { return false; }
1281 #endregion Public Properties
1283 #region Private Properties
1284 internal ArrayList ObjectItems {
1285 get { return object_items;}
1287 object_items = value;
1291 internal ArrayList ListBoxItems {
1292 get { return combobox_items;}
1294 combobox_items = value;
1297 #endregion Private Properties
1299 #region Public Methods
1300 public int Add (object item)
1304 idx = AddItem (item);
1305 owner.UpdatedItems ();
1309 public void AddRange (object[] items)
1311 foreach (object mi in items)
1314 owner.UpdatedItems ();
1317 public virtual void Clear ()
1319 owner.selected_index = -1;
1320 object_items.Clear ();
1321 combobox_items.Clear ();
1322 owner.UpdatedItems ();
1326 public virtual bool Contains (object obj)
1328 return object_items.Contains (obj);
1331 public void CopyTo (object[] dest, int arrayIndex)
1333 object_items.CopyTo (dest, arrayIndex);
1336 void ICollection.CopyTo (Array dest, int index)
1338 object_items.CopyTo (dest, index);
1341 public virtual IEnumerator GetEnumerator ()
1343 return object_items.GetEnumerator ();
1346 int IList.Add (object item)
1351 public virtual int IndexOf (object value)
1353 return object_items.IndexOf (value);
1356 public virtual void Insert (int index, object item)
1358 if (index < 0 || index > Count)
1359 throw new ArgumentOutOfRangeException ("Index of out range");
1361 ObjectCollection new_items = new ObjectCollection (owner);
1362 object sel_item = owner.SelectedItem;
1364 owner.BeginUpdate ();
1366 for (int i = 0; i < index; i++) {
1367 new_items.AddItem (ObjectItems[i]);
1370 new_items.AddItem (item);
1372 for (int i = index; i < Count; i++){
1373 new_items.AddItem (ObjectItems[i]);
1376 ObjectItems = new_items.ObjectItems;
1377 ListBoxItems = new_items.ListBoxItems;
1379 if (sel_item != null) {
1380 int idx = IndexOf (sel_item);
1381 owner.selected_index = idx;
1382 owner.listbox_ctrl.SetHighLightedItem (owner.Items[idx]);
1385 owner.EndUpdate (); // Calls UpdatedItems
1388 public virtual void Remove (object value)
1390 if (IndexOf (value) == owner.SelectedIndex)
1391 owner.SelectedItem = null;
1393 RemoveAt (IndexOf (value));
1397 public virtual void RemoveAt (int index)
1399 if (index < 0 || index >= Count)
1400 throw new ArgumentOutOfRangeException ("Index of out range");
1402 if (index == owner.SelectedIndex)
1403 owner.SelectedItem = null;
1405 object_items.RemoveAt (index);
1406 combobox_items.RemoveAt (index);
1407 owner.UpdatedItems ();
1409 #endregion Public Methods
1411 #region Private Methods
1412 private int AddItem (object item)
1414 int cnt = object_items.Count;
1415 object_items.Add (item);
1416 combobox_items.Add (new ComboBox.ComboBoxItem (cnt));
1420 internal void AddRange (IList items)
1422 foreach (object mi in items)
1425 owner.UpdatedItems ();
1428 internal ComboBox.ComboBoxItem GetComboBoxItem (int index)
1430 if (index < 0 || index >= Count)
1431 throw new ArgumentOutOfRangeException ("Index of out range");
1433 return (ComboBox.ComboBoxItem) combobox_items[index];
1436 internal void SetComboBoxItem (ComboBox.ComboBoxItem item, int index)
1438 if (index < 0 || index >= Count)
1439 throw new ArgumentOutOfRangeException ("Index of out range");
1441 combobox_items[index] = item;
1444 #endregion Private Methods
1450 internal class ComboListBox : Control
1452 private ComboBox owner;
1453 private VScrollBarLB vscrollbar_ctrl;
1454 private int top_item; /* First item that we show the in the current page */
1455 private int last_item; /* Last visible item */
1456 public object highlighted_item; /* Item that is currently selected */
1457 internal int page_size; /* Number of listbox items per page */
1458 private Rectangle textarea_drawable; /* Rectangle of the drawable text area */
1460 internal enum ItemNavigation
1470 class VScrollBarLB : VScrollBar
1472 public VScrollBarLB ()
1476 public void FireMouseDown (MouseEventArgs e)
1481 public void FireMouseUp (MouseEventArgs e)
1486 public void FireMouseMove (MouseEventArgs e)
1493 public ComboListBox (ComboBox owner) : base ()
1499 highlighted_item = null;
1501 MouseDown += new MouseEventHandler (OnMouseDownPUW);
1502 MouseUp += new MouseEventHandler (OnMouseUpPUW);
1503 MouseMove += new MouseEventHandler (OnMouseMovePUW);
1504 KeyDown += new KeyEventHandler (OnKeyDownPUW);
1505 Paint += new PaintEventHandler (OnPaintPUW);
1506 SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
1507 SetStyle (ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);
1510 protected override CreateParams CreateParams
1513 CreateParams cp = base.CreateParams;
1514 if (owner != null && owner.DropDownStyle != ComboBoxStyle.Simple) {
1515 cp.Style ^= (int) WindowStyles.WS_CHILD;
1516 cp.Style |= (int) WindowStyles.WS_POPUP;
1517 cp.ExStyle |= (int)(WindowStyles.WS_EX_TOOLWINDOW | WindowStyles.WS_EX_TOPMOST);
1523 #region Private Methods
1524 // Calcs the listbox area
1525 internal void CalcListBoxArea ()
1528 int item_height = owner.ItemHeight;
1529 bool show_scrollbar = false;
1531 if (owner.DropDownStyle == ComboBoxStyle.Simple) {
1532 width = owner.CBoxInfo.listbox_area.Width;
1533 height = owner.CBoxInfo.listbox_area.Height;
1535 if (owner.IntegralHeight == true) {
1536 int remaining = (height -
1537 ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
1538 ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle)) %
1541 if (remaining > 0) {
1542 height -= remaining;
1546 else { // DropDown or DropDownList
1548 width = owner.DropDownWidth;
1549 int count = (owner.Items.Count <= owner.MaxDropDownItems) ? owner.Items.Count : owner.MaxDropDownItems;
1551 if (owner.DrawMode == DrawMode.OwnerDrawVariable) {
1553 for (int i = 0; i < count; i++) {
1554 height += owner.GetItemHeight (i);
1558 height = (item_height - 2) * count;
1562 height += ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle);
1563 height += ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
1566 if (owner.Items.Count <= owner.MaxDropDownItems) {
1568 /* Does not need vertical scrollbar*/
1569 if (vscrollbar_ctrl != null) {
1570 vscrollbar_ctrl.Visible = false;
1574 /* Need vertical scrollbar */
1575 if (vscrollbar_ctrl == null) {
1576 vscrollbar_ctrl = new VScrollBarLB ();
1577 vscrollbar_ctrl.Minimum = 0;
1578 vscrollbar_ctrl.SmallChange = 1;
1579 vscrollbar_ctrl.LargeChange = 1;
1580 vscrollbar_ctrl.Maximum = 0;
1581 vscrollbar_ctrl.ValueChanged += new EventHandler (VerticalScrollEvent);
1583 Controls.AddImplicit (vscrollbar_ctrl);
1586 vscrollbar_ctrl.Height = height - ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle) -
1587 ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
1589 vscrollbar_ctrl.Location = new Point (width - vscrollbar_ctrl.Width - ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle),
1590 ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle));
1592 vscrollbar_ctrl.Maximum = owner.Items.Count - (owner.DropDownStyle == ComboBoxStyle.Simple ? page_size : owner.maxdrop_items);
1593 show_scrollbar = vscrollbar_ctrl.Visible = true;
1595 int hli = GetHighLightedIndex ();
1597 hli = Math.Min (hli, vscrollbar_ctrl.Maximum);
1598 vscrollbar_ctrl.Value = hli;
1602 Size = new Size (width, height);
1603 textarea_drawable = ClientRectangle;
1604 textarea_drawable.Width = width;
1605 textarea_drawable.Height = height;
1607 // Exclude decorations
1608 textarea_drawable.X += ThemeEngine.Current.DrawComboListBoxDecorationLeft (owner.DropDownStyle);
1609 textarea_drawable.Y += ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
1610 textarea_drawable.Width -= ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle);
1611 textarea_drawable.Width -= ThemeEngine.Current.DrawComboListBoxDecorationLeft (owner.DropDownStyle);
1612 textarea_drawable.Height -= ThemeEngine.Current.DrawComboListBoxDecorationBottom (owner.DropDownStyle);
1613 textarea_drawable.Height -= ThemeEngine.Current.DrawComboListBoxDecorationTop (owner.DropDownStyle);
1615 if (vscrollbar_ctrl != null && show_scrollbar)
1616 textarea_drawable.Width -= vscrollbar_ctrl.Width;
1618 last_item = LastVisibleItem ();
1619 page_size = textarea_drawable.Height / (item_height - 2);
1622 private void Draw (Rectangle clip, Graphics dc)
1624 dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
1625 (owner.BackColor), clip);
1627 if (owner.Items.Count > 0) {
1628 Rectangle item_rect;
1629 DrawItemState state = DrawItemState.None;
1631 for (int i = top_item; i <= last_item; i++) {
1632 item_rect = GetItemDisplayRectangle (i, top_item);
1634 if (clip.IntersectsWith (item_rect) == false)
1638 state = DrawItemState.None;
1640 if (i == GetHighLightedIndex () ) {
1641 state |= DrawItemState.Selected;
1643 if (owner.DropDownStyle == ComboBoxStyle.DropDownList) {
1644 state |= DrawItemState.Focus;
1648 owner.OnDrawItem (new DrawItemEventArgs (dc, owner.Font, item_rect,
1649 i, state, owner.ForeColor, owner.BackColor));
1653 ThemeEngine.Current.DrawComboListBoxDecorations (dc, owner, ClientRectangle);
1656 public int GetHighLightedIndex ()
1658 return owner.Items.IndexOf (highlighted_item);
1661 public object GetHighLightedItem ()
1663 return highlighted_item;
1666 private Rectangle GetItemDisplayRectangle (int index, int first_displayble)
1668 if (index < 0 || index >= owner.Items.Count)
1669 throw new ArgumentOutOfRangeException ("GetItemRectangle index out of range.");
1671 Rectangle item_rect = new Rectangle ();
1672 int height = owner.GetItemHeight (index);
1674 item_rect.X = ThemeEngine.Current.DrawComboListBoxDecorationRight (owner.DropDownStyle);
1675 item_rect.Width = textarea_drawable.Width;
1676 item_rect.Y = ((height - 2) * (index - first_displayble));
1678 if (owner.dropdown_style == ComboBoxStyle.Simple)
1681 item_rect.Height = height;
1685 public void HideWindow ()
1687 if (owner.DropDownStyle == ComboBoxStyle.Simple)
1692 highlighted_item = -1;
1693 owner.DropDownListBoxFinished ();
1696 private int IndexFromPointDisplayRectangle (int x, int y)
1698 for (int i = top_item; i <= last_item; i++) {
1699 if (GetItemDisplayRectangle (i, top_item).Contains (x, y) == true)
1706 protected override bool IsInputKey (Keys keyData)
1708 return owner.IsInputKey (keyData);
1711 private int LastVisibleItem ()
1713 Rectangle item_rect;
1714 int top_y = textarea_drawable.Y + textarea_drawable.Height;
1717 for (i = top_item; i < owner.Items.Count; i++) {
1718 item_rect = GetItemDisplayRectangle (i, top_item);
1719 if (item_rect.Y + item_rect.Height > top_y) {
1726 private void NavigateItemVisually (ItemNavigation navigation)
1730 switch (navigation) {
1731 case ItemNavigation.Next: {
1732 if (GetHighLightedIndex () + 1 < owner.Items.Count) {
1734 if (GetHighLightedIndex () + 1 > last_item) {
1736 vscrollbar_ctrl.Value = top_item;
1738 item = GetHighLightedIndex () + 1;
1743 case ItemNavigation.Previous: {
1744 if (GetHighLightedIndex () > 0) {
1746 if (GetHighLightedIndex () - 1 < top_item) {
1748 vscrollbar_ctrl.Value = top_item;
1750 item = GetHighLightedIndex () - 1;
1755 case ItemNavigation.NextPage: {
1756 if (GetHighLightedIndex () + page_size - 1 >= owner.Items.Count) {
1757 top_item = owner.Items.Count - page_size;
1758 vscrollbar_ctrl.Value = top_item;
1759 item = owner.Items.Count - 1;
1762 if (GetHighLightedIndex () + page_size - 1 > last_item) {
1763 top_item = GetHighLightedIndex ();
1764 vscrollbar_ctrl.Value = GetHighLightedIndex ();
1767 item = GetHighLightedIndex () + page_size - 1;
1772 case ItemNavigation.PreviousPage: {
1774 /* Go to the first item*/
1775 if (GetHighLightedIndex () - (page_size - 1) <= 0) {
1778 vscrollbar_ctrl.Value = top_item;
1781 else { /* One page back */
1782 if (GetHighLightedIndex () - (page_size - 1) < top_item) {
1783 top_item = GetHighLightedIndex () - (page_size - 1);
1784 vscrollbar_ctrl.Value = top_item;
1787 item = GetHighLightedIndex () - (page_size - 1);
1798 SetHighLightedItem (owner.Items[item]);
1800 owner.OnSelectionChangeCommitted (new EventArgs ());
1802 if (owner.DropDownStyle == ComboBoxStyle.Simple) {
1803 owner.SetControlText (owner.GetItemText (owner.Items[item]));
1808 private void OnKeyDownPUW (object sender, KeyEventArgs e)
1810 switch (e.KeyCode) {
1812 NavigateItemVisually (ItemNavigation.Previous);
1816 NavigateItemVisually (ItemNavigation.Next);
1820 NavigateItemVisually (ItemNavigation.PreviousPage);
1824 NavigateItemVisually (ItemNavigation.NextPage);
1832 public void SetHighLightedItem (object item)
1834 Rectangle invalidate = Rectangle.Empty;
1837 if (GetHighLightedItem () == item)
1841 hli = GetHighLightedIndex ();
1843 invalidate = GetItemDisplayRectangle (hli, top_item);
1846 highlighted_item = item;
1848 if (highlighted_item != null) {
1850 invalidate = Rectangle.Union (invalidate,
1851 GetItemDisplayRectangle (GetHighLightedIndex (), top_item));
1855 if (ClientRectangle.IntersectsWith (invalidate))
1856 Invalidate (invalidate);
1859 public void SetTopItem (int item)
1862 UpdateLastVisibleItem ();
1866 private void OnMouseDownPUW (object sender, MouseEventArgs e)
1868 Rectangle scrollbar_screenrect;
1869 Point mouse_screen, scrollbar_screen;
1870 mouse_screen = PointToScreen (new Point (e.X, e.Y));
1872 /* Click on an element ? */
1873 int index = IndexFromPointDisplayRectangle (e.X, e.Y);
1875 owner.SelectedIndex = index;
1876 SetHighLightedItem (owner.Items[index]);
1877 owner.OnSelectionChangeCommitted (new EventArgs ());
1882 if (owner.DropDownStyle == ComboBoxStyle.Simple)
1885 /* Reroute event to scrollbar */
1886 if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
1887 scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
1888 scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
1889 scrollbar_screenrect.X = scrollbar_screen.X;
1890 scrollbar_screenrect.Y = scrollbar_screen.Y;
1892 if (scrollbar_screenrect.Contains (mouse_screen)){
1893 Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
1894 vscrollbar_ctrl.FireMouseDown (new MouseEventArgs (e.Button, e.Clicks,
1895 pnt_client.X, pnt_client.Y, e.Delta));
1896 } else { /* Click in a non-client area*/
1899 } else { /* Click in a non-client area*/
1904 private void OnMouseMovePUW (object sender, MouseEventArgs e)
1906 if (owner.DropDownStyle == ComboBoxStyle.Simple)
1909 int index = IndexFromPointDisplayRectangle (e.X, e.Y);
1912 SetHighLightedItem (owner.Items[index]);
1916 if (owner.DropDownStyle == ComboBoxStyle.Simple)
1919 /* Reroute event to scrollbar */
1920 if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
1921 Rectangle scrollbar_screenrect;
1922 Point mouse_screen, scrollbar_screen;
1923 mouse_screen = PointToScreen (new Point (e.X, e.Y));
1925 scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
1926 scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
1927 scrollbar_screenrect.X = scrollbar_screen.X;
1928 scrollbar_screenrect.Y = scrollbar_screen.Y;
1930 if (scrollbar_screenrect.Contains (mouse_screen)){
1931 Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
1933 vscrollbar_ctrl.FireMouseMove (new MouseEventArgs (e.Button, e.Clicks,
1934 pnt_client.X, pnt_client.Y, e.Delta));
1939 private void OnMouseUpPUW (object sender, MouseEventArgs e)
1941 if (owner.DropDownStyle == ComboBoxStyle.Simple)
1944 /* Reroute event to scrollbar */
1945 Rectangle scrollbar_screenrect;
1946 Point mouse_screen, scrollbar_screen;
1947 mouse_screen = PointToScreen (new Point (e.X, e.Y));
1949 if (vscrollbar_ctrl != null && vscrollbar_ctrl.Visible == true) {
1950 scrollbar_screenrect = vscrollbar_ctrl.ClientRectangle;
1951 scrollbar_screen = PointToScreen (vscrollbar_ctrl.Location);
1952 scrollbar_screenrect.X = scrollbar_screen.X;
1953 scrollbar_screenrect.Y = scrollbar_screen.Y;
1955 if (scrollbar_screenrect.Contains (mouse_screen)){
1956 Point pnt_client = vscrollbar_ctrl.PointToClient (mouse_screen);
1958 vscrollbar_ctrl.FireMouseUp (new MouseEventArgs (e.Button, e.Clicks,
1959 pnt_client.X, pnt_client.Y, e.Delta));
1964 private void OnPaintPUW (Object o, PaintEventArgs pevent)
1966 Draw (pevent.ClipRectangle,pevent.Graphics);
1969 public bool ShowWindow ()
1971 if (owner.DropDownStyle != ComboBoxStyle.Simple && owner.Items.Count == 0)
1974 SetHighLightedItem (owner.SelectedItem);
1975 int index = GetHighLightedIndex ();
1980 if (owner.DropDownStyle != ComboBoxStyle.Simple) {
1986 if (owner.DropDown != null) {
1987 owner.DropDown (owner, EventArgs.Empty);
1993 public void UpdateLastVisibleItem ()
1995 last_item = LastVisibleItem ();
1999 private void VerticalScrollEvent (object sender, EventArgs e)
2001 if (top_item == vscrollbar_ctrl.Value)
2004 top_item = vscrollbar_ctrl.Value;
2005 UpdateLastVisibleItem ();
2009 #endregion Private Methods