XAF去掉View页面的编辑器

XAF去掉View页面的编辑器_第1张图片

 

如图,去掉该编辑器功能。

1、detailView

  protected override void OnActivated()
        {
            base.OnActivated();
            // Perform various tasks depending on the target View.
            foreach (IntegerPropertyEditor propertyEditor in View.GetItems()) {
            propertyEditor.ControlCreated += new EventHandler(propertyEditor_ControlCreated);
            }
            
             
        }
        
        void propertyEditor_ControlCreated(object sender, EventArgs e)
        {
            SpinEdit spinEdit = ((IntegerPropertyEditor)sender).Control;
            spinEdit.Properties.Buttons[spinEdit.Properties.SpinButtonIndex].Visible = false;
            spinEdit.Properties.AllowMouseWheel = false;
        } 

2、listView

protected override void OnActivated()
{
base.OnActivated();
// Perform various tasks depending on the target View.
//if (View is DetailView)
//{
// foreach (DXPropertyEditor editor in ((DetailView)View).GetItems())
// {
// editor.ControlCreated += new EventHandler(editor_ControlCreated);
// }
//}
if (View is ListView)
{
((ListView)View).Editor.ControlsCreated += new EventHandler(listEditor_ControlsCreated);
}

}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();

}
void listEditor_ControlsCreated(object sender, EventArgs e)
{
ListEditor editor = (ListEditor)sender;
editor.ControlsCreated -= new EventHandler(listEditor_ControlsCreated);
GridListEditor gridListEditor = editor as GridListEditor;
if (gridListEditor == null || gridListEditor.GridView == null) return;
gridListEditor.GridView.ShownEditor += new EventHandler(GridView_ShownEditor);
}
void GridView_ShownEditor(object sender, EventArgs e)
{
CustomizeEditor(((XafGridView)sender).ActiveEditor);
}
void editor_ControlCreated(object sender, EventArgs e)
{
DXPropertyEditor editor = (DXPropertyEditor)sender;
editor.ControlCreated -= new EventHandler(editor_ControlCreated);
CustomizeEditor(editor.Control);
}
private void CustomizeEditor(DevExpress.XtraEditors.BaseEdit baseEdit)
{
// baseEdit.Properties.AllowMouseWheel = false;
baseEdit.Properties.AllowMouseWheel = false;
DevExpress.XtraEditors.TextEdit textEdit = baseEdit as DevExpress.XtraEditors.TextEdit;

if (textEdit == null) return;
textEdit.Spin += (object sender2, DevExpress.XtraEditors.Controls.SpinEventArgs e) => { e.Handled = true; };
}

你可能感兴趣的:(XAF去掉View页面的编辑器)