Commit bdfee2a5 HZH

修改列表控件清空

1 个父辈 1ab11397
......@@ -125,7 +125,11 @@ namespace HZH_Controls.Controls
set
{
if (value == null)
{
m_dataSource = value;
ReloadSource();
return;
}
if (!typeof(IList).IsAssignableFrom(value.GetType()))
{
throw new Exception("数据源不是有效的数据类型,列表");
......@@ -233,9 +237,12 @@ namespace HZH_Controls.Controls
/// </summary>
public void ReloadSource()
{
try
{
if (DesignMode)
return;
ControlHelper.FreezeControl(this, true);
if (this.panMain.Controls.Count <= 0)
{
ReloadGridStyle();
......@@ -270,8 +277,13 @@ namespace HZH_Controls.Controls
if (this.panMain.Controls[i].Visible)
this.panMain.Controls[i].Visible = false;
}
}
finally
{
ControlHelper.FreezeControl(this, false);
}
}
#endregion
#region 刷新表格
......
......@@ -73,10 +73,22 @@ namespace HZH_Controls.Controls
}
set
{
base.DataSource = value;
if (base.DataSource == null)
if (value == null)
{
base.DataSource = new List<object>();
}
else
{
base.DataSource = value;
}
PageIndex = 1;
ResetPageCount();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
}
......
......@@ -97,11 +97,19 @@ namespace HZH_Controls.Controls
get { return m_pageIndex; }
set { m_pageIndex = value; }
}
private List<object> dataSource;
/// <summary>
/// 关联的数据源
/// </summary>
/// <value>The data source.</value>
public virtual List<object> DataSource { get; set; }
public virtual List<object> DataSource
{
get { return dataSource; }
set
{
dataSource = value;
}
}
/// <summary>
/// 数据源改变时发生
/// </summary>
......@@ -167,8 +175,6 @@ namespace HZH_Controls.Controls
/// </summary>
public virtual void FirstPage()
{
if (DataSource == null)
return;
startIndex = 0;
var s = GetCurrentSource();
......@@ -182,8 +188,6 @@ namespace HZH_Controls.Controls
/// </summary>
public virtual void PreviousPage()
{
if (DataSource == null)
return;
if (startIndex == 0)
return;
startIndex -= m_pageSize;
......@@ -201,8 +205,7 @@ namespace HZH_Controls.Controls
/// </summary>
public virtual void NextPage()
{
if (DataSource == null)
return;
if (startIndex + m_pageSize >= DataSource.Count)
{
return;
......@@ -223,7 +226,13 @@ namespace HZH_Controls.Controls
public virtual void EndPage()
{
if (DataSource == null)
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(null);
}
return;
}
startIndex = DataSource.Count - m_pageSize;
if (startIndex < 0)
startIndex = 0;
......@@ -251,7 +260,7 @@ namespace HZH_Controls.Controls
/// <returns>List&lt;System.Object&gt;.</returns>
public virtual List<object> GetCurrentSource()
{
if (DataSource == null)
if (DataSource == null || DataSource.Count <= 0)
return null;
int intShowCount = m_pageSize;
if (intShowCount + startIndex > DataSource.Count)
......
......@@ -16,6 +16,12 @@ namespace Test
public FrmTestListView()
{
InitializeComponent();
BtnHelpClick += FrmTestListView_BtnHelpClick;
}
void FrmTestListView_BtnHelpClick(object sender, EventArgs e)
{
this.ucListView1.Page.DataSource = null;
}
private void FrmTestListView_Load(object sender, EventArgs e)
......@@ -33,5 +39,7 @@ namespace Test
//this.ucListView1.DataSource = lstSource;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!