#if NET_2_0
using System.Drawing;
using System.ComponentModel;
+using System.Windows.Forms.Design;
namespace System.Windows.Forms
{
[DefaultProperty ("Items")]
+ [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripComboBox : ToolStripControlHost
{
#region Public Constructors
{
}
+ [EditorBrowsable (EditorBrowsableState.Never)]
public ToolStripComboBox (Control c) : base (c)
{
throw new NotSupportedException ();
public ToolStripComboBox (string name) : this ()
{
- base.Control.Name = name;
+ base.Name = name;
}
#endregion
#region Public Properties
[Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set { base.BackgroundImage = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override ImageLayout BackgroundImageLayout {
+ get { return base.BackgroundImageLayout; }
+ set { base.BackgroundImageLayout = value; }
+ }
+
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public ComboBox ComboBox {
get { return (ComboBox)base.Control; }
}
+ [MonoTODO ("Stub, will not actually affect anything.")]
+ [Browsable (false)]
+ [DefaultValue (106)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public int DropDownHeight {
+ get { return 106; }
+ set { }
+ }
+
[DefaultValue (ComboBoxStyle.DropDown)]
+ [RefreshProperties (RefreshProperties.All)]
public ComboBoxStyle DropDownStyle {
get { return this.ComboBox.DropDownStyle; }
set { this.ComboBox.DropDownStyle = value; }
}
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public bool DroppedDown {
get { return this.ComboBox.DroppedDown; }
set { this.ComboBox.DroppedDown = value; }
}
[Localizable (true)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ [Editor ("System.Windows.Forms.Design.ListControlStringCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
public ComboBox.ObjectCollection Items {
get { return this.ComboBox.Items; }
}
}
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int SelectedIndex {
get { return this.ComboBox.SelectedIndex; }
- set { this.ComboBox.SelectedIndex = value; }
+ set {
+ this.ComboBox.SelectedIndex = value;
+ Text = Items [value].ToString ();
+ }
}
[Bindable (true)]
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public Object SelectedItem {
get { return this.ComboBox.SelectedItem; }
set { this.ComboBox.SelectedItem = value; }
}
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public string SelectedText {
get { return this.ComboBox.SelectedText; }
set { this.ComboBox.SelectedText = value; }
}
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int SelectionLength {
get { return this.ComboBox.SelectionLength; }
set { this.ComboBox.SelectionLength = value; }
}
[Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int SelectionStart {
get { return this.ComboBox.SelectionStart; }
set { this.ComboBox.SelectionStart = value; }
#endregion
#region Protected Properties
- protected internal override Padding DefaultMargin { get { return new Padding (2); } }
+ protected internal override Padding DefaultMargin { get { return new Padding (1, 0, 1, 0); } }
protected override Size DefaultSize { get { return new Size (100, 22); } }
#endregion
#region Protected Methods
protected virtual void OnDropDown (EventArgs e)
{
- if (DropDown != null) DropDown (this, e);
+ EventHandler eh = (EventHandler)(Events [DropDownEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnDropDownClosed (EventArgs e)
{
- if (DropDownClosed != null) DropDownClosed (this, e);
+ EventHandler eh = (EventHandler)(Events [DropDownClosedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnDropDownStyleChanged (EventArgs e)
{
- if (DropDownStyleChanged != null) DropDownStyleChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [DropDownStyleChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnSelectedIndexChanged (EventArgs e)
{
- if (SelectedIndexChanged != null) SelectedIndexChanged (this, e);
+ EventHandler eh = (EventHandler)(Events [SelectedIndexChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected virtual void OnSelectionChangeCommitted (EventArgs e)
protected virtual void OnTextUpdate (EventArgs e)
{
- if (TextUpdate != null) TextUpdate (this, e);
+ EventHandler eh = (EventHandler)(Events [TextUpdateEvent]);
+ if (eh != null)
+ eh (this, e);
}
protected override void OnUnsubscribeControlEvents (Control control)
#endregion
#region Public Events
+ static object DropDownEvent = new object ();
+ static object DropDownClosedEvent = new object ();
+ static object DropDownStyleChangedEvent = new object ();
+ static object SelectedIndexChangedEvent = new object ();
+ static object TextUpdateEvent = new object ();
+
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
- public event EventHandler DoubleClick;
- public event EventHandler DropDown;
- public event EventHandler DropDownClosed;
- public event EventHandler DropDownStyleChanged;
- public event EventHandler SelectedIndexChanged;
- public event EventHandler TextUpdate;
+ public new event EventHandler DoubleClick {
+ add { base.DoubleClick += value; }
+ remove { base.DoubleClick -= value; }
+ }
+
+ public event EventHandler DropDown {
+ add { Events.AddHandler (DropDownEvent, value); }
+ remove { Events.RemoveHandler (DropDownEvent, value); }
+ }
+
+ public event EventHandler DropDownClosed {
+ add { Events.AddHandler (DropDownClosedEvent, value); }
+ remove { Events.RemoveHandler (DropDownClosedEvent, value); }
+ }
+
+ public event EventHandler DropDownStyleChanged {
+ add { Events.AddHandler (DropDownStyleChangedEvent, value); }
+ remove { Events.RemoveHandler (DropDownStyleChangedEvent, value); }
+ }
+
+ public event EventHandler SelectedIndexChanged {
+ add { Events.AddHandler (SelectedIndexChangedEvent, value); }
+ remove { Events.RemoveHandler (SelectedIndexChangedEvent, value); }
+ }
+
+ public event EventHandler TextUpdate {
+ add { Events.AddHandler (TextUpdateEvent, value); }
+ remove { Events.RemoveHandler (TextUpdateEvent, value); }
+ }
#endregion
#region Private Methods
private void HandleDropDownStyleChanged (object sender, EventArgs e)
{
- OnDisplayStyleChanged (e);
+ OnDropDownStyleChanged (e);
}
private void HandleSelectedIndexChanged (object sender, EventArgs e)