Exposed list properties on KComboBox

This commit is contained in:
Patrick Simpson 2017-06-21 16:08:38 +02:00
parent ed1892b3d7
commit 72fa30189e
2 changed files with 63 additions and 11 deletions

View File

@ -18,6 +18,29 @@ namespace Acacia.Controls
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
override public bool AutoSize { get { return base.AutoSize; } set { base.AutoSize = value; } } override public bool AutoSize { get { return base.AutoSize; } set { base.AutoSize = value; } }
[Category("Appearance")]
[Localizable(true)]
public string Placeholder
{
get { return _edit.Placeholder; }
set { _edit.Placeholder = value; }
}
[Category("Appearance")]
public Color PlaceholderColor
{
get { return _edit.PlaceholderColor; }
set { _edit.PlaceholderColor = value; }
}
[Category("Appearance")]
public Font PlaceholderFont
{
get { return _edit.PlaceholderFont; }
set { _edit.PlaceholderFont = value; }
}
#endregion #endregion
#region Components #region Components
@ -35,7 +58,6 @@ namespace Acacia.Controls
_edit = new KTextBox(); _edit = new KTextBox();
_edit.BorderStyle = BorderStyle.None; _edit.BorderStyle = BorderStyle.None;
_edit.Placeholder = "Test";
Controls.Add(_edit); Controls.Add(_edit);
_state.AddControl(_edit); _state.AddControl(_edit);
_edit.TextChanged += _edit_TextChanged; _edit.TextChanged += _edit_TextChanged;
@ -198,6 +220,7 @@ namespace Acacia.Controls
this._edit.Focus(); this._edit.Focus();
} }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool DroppedDown public bool DroppedDown
{ {
get get

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Design;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -10,37 +12,64 @@ namespace Acacia.Controls
{ {
public class KComboBox : KAbstractComboBox public class KComboBox : KAbstractComboBox
{ {
private readonly ListBox _dropList; private readonly ListBox _list;
#region Items properties
[DefaultValue(true)]
[Localizable(true)]
[Category("Behavior")]
public bool IntegralHeight { get { return _list.IntegralHeight; } set { _list.IntegralHeight = value; } }
[DefaultValue(13)]
[Localizable(true)]
[Category("Behavior")]
public int ItemHeight { get { return _list.ItemHeight; } set { _list.ItemHeight = value; } }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Localizable(true)]
[MergableProperty(false)]
[Category("Behavior")]
public ListBox.ObjectCollection Items { get { return _list.Items; } }
[DefaultValue(8)]
[Localizable(true)]
[Category("Behavior")]
public int MaxDropDownItems { get; set; }
#endregion
public KComboBox() public KComboBox()
{ {
_dropList = new ListBox(); MaxDropDownItems = 8;
_dropList.IntegralHeight = true; _list = new ListBox();
DropControl = _dropList; _list.IntegralHeight = true;
_dropList.DisplayMember = "DisplayName"; // TODO: remove from here DropControl = _list;
_list.DisplayMember = "DisplayName"; // TODO: remove from here
} }
public void BeginUpdate() public void BeginUpdate()
{ {
_dropList.BeginUpdate(); _list.BeginUpdate();
} }
public void EndUpdate() public void EndUpdate()
{ {
_dropList.EndUpdate(); _list.EndUpdate();
} }
public object DataSource public object DataSource
{ {
get get
{ {
return _dropList.DataSource; return _list.DataSource;
} }
set set
{ {
_dropList.BindingContext = new BindingContext(); _list.BindingContext = new BindingContext();
_dropList.DataSource = value; _list.DataSource = value;
} }
} }
} }