* UIDataGridView: 不再判断DataSource绑定List为空,出现”索引-1没有值“用户自行判断

This commit is contained in:
Sunny 2022-06-10 17:59:38 +08:00
parent d1b3e3bcd6
commit e415486a50

View File

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