Commit b31801cb HZH

验证组件自动关闭

1 个父辈 1a875382
...@@ -103,6 +103,20 @@ namespace HZH_Controls.Controls ...@@ -103,6 +103,20 @@ namespace HZH_Controls.Controls
set { errorTipsForeColor = value; } set { errorTipsForeColor = value; }
} }
private int autoCloseErrorTipsTime = 3000;
[Browsable(true), Category("自定义属性"), Description("自动关闭提示事件,当值为0时不自动关闭"), Localizable(true)]
public int AutoCloseErrorTipsTime
{
get { return autoCloseErrorTipsTime; }
set
{
if (value < 0)
return;
autoCloseErrorTipsTime = value;
}
}
#region 构造函数 English:Constructor #region 构造函数 English:Constructor
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VerificationComponent"/> class. /// Initializes a new instance of the <see cref="VerificationComponent"/> class.
...@@ -438,11 +452,64 @@ namespace HZH_Controls.Controls ...@@ -438,11 +452,64 @@ namespace HZH_Controls.Controls
} }
else else
{ {
var tips = Forms.FrmAnchorTips.ShowTips(e.VerificationControl, e.ErrorMsg, background: errorTipsBackColor, foreColor: errorTipsForeColor, autoCloseTime: 0, blnTopMost: false); var tips = Forms.FrmAnchorTips.ShowTips(e.VerificationControl, e.ErrorMsg, background: errorTipsBackColor, foreColor: errorTipsForeColor, autoCloseTime: autoCloseErrorTipsTime, blnTopMost: false);
tips.FormClosing += tips_FormClosing;
m_controlTips[e.VerificationControl] = tips; m_controlTips[e.VerificationControl] = tips;
} }
} }
} }
#endregion
void tips_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (var item in m_controlTips)
{
if (item.Value == sender)
{
m_controlTips.Remove(item.Key);
break;
}
}
}
#endregion
/// <summary>
/// 关闭所有错误提示
/// </summary>
public void CloseErrorTips()
{
for (int i = 0; i < 1; )
{
try
{
foreach (var item in m_controlTips)
{
if (item.Value != null && !item.Value.IsDisposed)
{
item.Value.Close();
}
}
}
catch
{
continue;
}
i++;
}
m_controlTips.Clear();
}
/// <summary>
/// 关闭指定验证控件的提示
/// </summary>
/// <param name="verificationControl">验证控件.</param>
public void CloseErrorTips(Control verificationControl)
{
if (m_controlTips.ContainsKey(verificationControl))
{
if (m_controlTips[verificationControl] != null && !m_controlTips[verificationControl].IsDisposed)
{
m_controlTips[verificationControl].Close();
}
}
}
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>$id$</id> <id>$id$</id>
<version>1.0.6</version> <version>1.0.7</version>
<title>HZHControls</title> <title>HZHControls</title>
<authors>HuangZhengHui</authors> <authors>HuangZhengHui</authors>
<owners>HuangZhengHui</owners> <owners>HuangZhengHui</owners>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!