From dc93db6fef81b17e572f293321a980a6c50e67f9 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期三, 24 七月 2024 08:59:13 +0800
Subject: [PATCH] 增加删除拓展方法

---
 WinFrmUI/Yw.WinFrmUI.Core/00-core/ListBoxControlExtensions.cs |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Core/00-core/ListBoxControlExtensions.cs b/WinFrmUI/Yw.WinFrmUI.Core/00-core/ListBoxControlExtensions.cs
index 14a4f0c..693cd87 100644
--- a/WinFrmUI/Yw.WinFrmUI.Core/00-core/ListBoxControlExtensions.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Core/00-core/ListBoxControlExtensions.cs
@@ -1,17 +1,36 @@
 锘縩amespace Yw.WinFrmUI
 {
     /// <summary>
-    /// 
+    ///
     /// </summary>
     public static class ListBoxControlExtensions
     {
         /// <summary>
-        /// 
+        ///
         /// </summary>
         public static void InitialDefaultSettings(this ListBoxControl listBox, int ItemHeight = 25)
         {
             listBox.ShowFocusRect = false;
             listBox.ItemHeight = ItemHeight;
         }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠鏁版嵁琛�
+        /// </summary>
+        public static T GetCurrentViewModel<T>(this ListBoxControl listBox, IEnumerable<T> source) where T : class
+        {
+            if (source == null)
+                return default;
+            if (source.Count() < 1)
+            {
+                return default;
+            }
+            var row = listBox.SelectedItem as T;
+            if (row == null)
+            {
+                return null;
+            }
+            return row;
+        }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3