| | |
| | | namespace 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; |
| | | } |
| | | } |
| | | } |
| | | } |