mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-02 07:09:27 +03:00
ListView now updates when item text changes
This commit is contained in:
parent
862002e0ef
commit
fc4ba9e6be
@ -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; }
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user