diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index b9040912..117e718b 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index d7731e3c..7c789d29 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll index af658300..5f7b47c9 100644 Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 7280ae89..058bb09b 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index 2f1fafec..fc03c987 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UIListBox.cs b/SunnyUI/Controls/UIListBox.cs index 6fc61954..09e57913 100644 --- a/SunnyUI/Controls/UIListBox.cs +++ b/SunnyUI/Controls/UIListBox.cs @@ -628,11 +628,34 @@ namespace Sunny.UI Color foreColor = isSelected ? ItemSelectForeColor : ForeColor; Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1); + string showText = string.Empty; + if (DisplayMember.IsNullOrEmpty()) + { + showText = Items[e.Index].ToString(); + } + else + { + var list = Items[e.Index].GetType().GetNeedProperties(); + foreach (var info in list) + { + if (info.Name == DisplayMember) + { + object defaultobj = info.GetValue(Items[e.Index], null); + showText = defaultobj.ToString(); + } + } + + if (showText.IsNullOrEmpty()) + { + showText = Items[e.Index].ToString(); + } + } + if (!otherState) { e.Graphics.FillRectangle(BackColor, e.Bounds); e.Graphics.FillRoundRectangle(backColor, rect, 5); - e.Graphics.DrawString(Items[e.Index].ToString(), e.Font, foreColor, e.Bounds, sStringFormat); + e.Graphics.DrawString(showText, e.Font, foreColor, e.Bounds, sStringFormat); } else { @@ -650,7 +673,7 @@ namespace Sunny.UI e.Graphics.FillRectangle(BackColor, e.Bounds); e.Graphics.FillRoundRectangle(backColor, rect, 5); - e.Graphics.DrawString(Items[e.Index].ToString(), e.Font, foreColor, e.Bounds, sStringFormat); + e.Graphics.DrawString(showText, e.Font, foreColor, e.Bounds, sStringFormat); } AfterDrawItem?.Invoke(this, Items, e);