* UIDataGridView: 解决原生控件DataSource绑定List,并且List为空,出现”索引-1没有值“错误

This commit is contained in:
Sunny 2022-04-26 14:44:23 +08:00
parent e093821c06
commit 4dc4636c69

View File

@ -29,9 +29,11 @@
* 2021-06-27: V3.0.4
* 2022-01-21: V3.1.0 SelectedIndex值
* 2022-04-16: V3.1.3
* 2022-04-26: V3.1.8 DataSource绑定ListList为空-1
******************************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
@ -101,6 +103,23 @@ namespace Sunny.UI
HorizontalScrollBar.VisibleChanged += HorizontalScrollBar_VisibleChanged;
}
[
DefaultValue(null),
RefreshProperties(RefreshProperties.Repaint),
AttributeProvider(typeof(IListSource)),
Description("提示 DataGridView 控件的数据源。")
]
public new object DataSource
{
get => base.DataSource;
set
{
//解决原生控件DataSource绑定List并且List为空出现”索引-1没有值“错误。
if (value is IList list && list.Count == 0) return;
base.DataSource = value;
}
}
[DefaultValue(false), Category("SunnyUI"), Description("禁止控件跟随窗体缩放")]
public bool ZoomScaleDisabled { get; set; }