1.在ViewController上添加两个ParameterAction
2.隐藏一个ParameterAction中的Action
3.实现代码:
private void ParermaterViewController_ViewControlsCreated(object sender, EventArgs e)
{
IBarManagerHolder bmh = Frame.Template as IBarManagerHolder;
if (bmh != null && bmh.BarManager != null)
{
foreach (BarItem item in bmh.BarManager.Items)
{
BarEditItem eitem = item as BarEditItem;
if (eitem != null && eitem.Tag == FromParaAction)
{
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).Buttons[1].Visible = false;
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).EditMask = "dd/MM/yyyy";
eitem.Width = 120;
eitem.AutoFillWidth = false;
eitem.Caption = FromParaAction.Caption;
//eitem.Edit.EditValueChanged += new EventHandler(FromAction_EditValueChanged);
}
else if (eitem != null && eitem.Tag == ToParaAction)
{
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).Buttons[1].Visible = true;
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).EditMask = "dd/MM/yyyy";
eitem.Width = 140;
eitem.AutoFillWidth = false;
eitem.Caption = ToParaAction.Caption;
//eitem.EditValue = DateTime.Now;
//eitem.Edit.EditValueChanged += new EventHandler(ToAction_EditValueChanged);
}
// BarButtonItem bitem = item as BarButtonItem;
//if (bitem != null && (bitem.Tag == ApplyFilterAction || bitem.Tag == RemoveFilterAction))
//{
// bitem.Width = 120;
//}
//foreach (BarItemLink itemLink in item.Links)
//{
// //if (itemLink != null && (itemLink.Caption == ApplyFilterAction.Caption || itemLink.Caption == RemoveFilterAction.Caption) )
// if (itemLink != null && (itemLink.Caption == ToAction.Caption || itemLink.Caption == RemoveFilterAction.Caption))
// {
// itemLink.BeginGroup = true;
// }
//}
}
}
}
{
IBarManagerHolder bmh = Frame.Template as IBarManagerHolder;
if (bmh != null && bmh.BarManager != null)
{
foreach (BarItem item in bmh.BarManager.Items)
{
BarEditItem eitem = item as BarEditItem;
if (eitem != null && eitem.Tag == FromParaAction)
{
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).Buttons[1].Visible = false;
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).EditMask = "dd/MM/yyyy";
eitem.Width = 120;
eitem.AutoFillWidth = false;
eitem.Caption = FromParaAction.Caption;
//eitem.Edit.EditValueChanged += new EventHandler(FromAction_EditValueChanged);
}
else if (eitem != null && eitem.Tag == ToParaAction)
{
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).Buttons[1].Visible = true;
((DevExpress.XtraEditors.Repository.RepositoryItemDateEdit)eitem.Edit).EditMask = "dd/MM/yyyy";
eitem.Width = 140;
eitem.AutoFillWidth = false;
eitem.Caption = ToParaAction.Caption;
//eitem.EditValue = DateTime.Now;
//eitem.Edit.EditValueChanged += new EventHandler(ToAction_EditValueChanged);
}
// BarButtonItem bitem = item as BarButtonItem;
//if (bitem != null && (bitem.Tag == ApplyFilterAction || bitem.Tag == RemoveFilterAction))
//{
// bitem.Width = 120;
//}
//foreach (BarItemLink itemLink in item.Links)
//{
// //if (itemLink != null && (itemLink.Caption == ApplyFilterAction.Caption || itemLink.Caption == RemoveFilterAction.Caption) )
// if (itemLink != null && (itemLink.Caption == ToAction.Caption || itemLink.Caption == RemoveFilterAction.Caption))
// {
// itemLink.BeginGroup = true;
// }
//}
}
}
}