using DevExpress.XtraEditors;
|
|
namespace IStation.Win
|
{
|
public static class ButtonEditExtend
|
{
|
|
/// <summary>
|
/// 设置查询
|
/// </summary>
|
/// <param name="btn"></param>
|
/// <param name="SearchData"></param>
|
/// <param name="RecoverData"></param>
|
public static void SetSearchSettings(this ButtonEdit btn, EventHandler SearchData, EventHandler RecoverData)
|
{
|
btn.Properties.Buttons.Clear();
|
btn.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
|
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Clear),
|
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Search)});
|
btn.Properties.Buttons[0].Visible = false;
|
btn.EditValueChanged += delegate
|
{
|
if (btn.EditValue == null || string.IsNullOrEmpty(btn.EditValue.ToString()))
|
{
|
btn.Properties.Buttons[0].Visible = false;
|
if (RecoverData != null)
|
RecoverData(null, null);
|
}
|
else
|
btn.Properties.Buttons[0].Visible = true;
|
|
};
|
btn.ButtonClick += (sender, e) =>
|
{
|
if (e.Button == btn.Properties.Buttons[0])
|
{
|
btn.EditValue = null;
|
if (RecoverData != null)
|
RecoverData(sender, e);
|
}
|
else if (SearchData != null)
|
{
|
if (RecoverData != null)
|
RecoverData(sender, e);
|
SearchData(sender, e);
|
}
|
};
|
btn.KeyPress += (sender, e) =>
|
{
|
if (e.KeyChar == 13)
|
{
|
if (RecoverData != null)
|
RecoverData(sender, e);
|
if (SearchData != null)
|
SearchData(sender, e);
|
}
|
};
|
|
|
}
|
|
|
}
|
}
|