diff --git a/DarkUI/Controls/DarkListItem.cs b/DarkUI/Controls/DarkListItem.cs index f3a797a..1070753 100644 --- a/DarkUI/Controls/DarkListItem.cs +++ b/DarkUI/Controls/DarkListItem.cs @@ -1,13 +1,36 @@ using DarkUI.Config; +using System; using System.Drawing; namespace DarkUI.Controls { public class DarkListItem { + #region Event Region + + public event EventHandler TextChanged; + + #endregion + + #region Field Region + + private string _text; + + #endregion + #region Property Region - public string Text { get; set; } + public string Text + { + get { return _text; } + set + { + _text = value; + + if (TextChanged != null) + TextChanged(this, new EventArgs()); + } + } public Rectangle Area { get; set; } diff --git a/DarkUI/Controls/DarkListView.cs b/DarkUI/Controls/DarkListView.cs index bf224c1..ea8d20c 100644 --- a/DarkUI/Controls/DarkListView.cs +++ b/DarkUI/Controls/DarkListView.cs @@ -95,7 +95,10 @@ namespace DarkUI.Controls { // Set the area size of all new items foreach (DarkListItem item in e.NewItems) + { + item.TextChanged += Item_TextChanged; UpdateItemSize(item, g); + } } // Find the starting index of the new item list and update anything past that @@ -110,6 +113,9 @@ namespace DarkUI.Controls if (e.OldItems != null) { + foreach (DarkListItem item in e.NewItems) + item.TextChanged -= Item_TextChanged; + // Find the starting index of the old item list and update anything past that if (e.OldStartingIndex < (Items.Count - 1)) { @@ -123,6 +129,11 @@ namespace DarkUI.Controls UpdateContentSize(); } + private void Item_TextChanged(object sender, EventArgs e) + { + UpdateContentSize(); + } + protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e);