![](file:///C:UsersTONG.YEDocumentsTencent Files869570858ImageGroup7@2JJ0TTJY75SRS8U8_SBS2.png)
![](file:///C:UsersTONG.YEDocumentsTencent Files869570858ImageGroup7@2JJ0TTJY75SRS8U8_SBS2.png)
如图,去掉该编辑器功能。
1、detailView
{
base.OnActivated();
// Perform various tasks depending on the target View.
foreach (IntegerPropertyEditor propertyEditor in View.GetItems<IntegerPropertyEditor>()) {
propertyEditor.ControlCreated += new EventHandler<EventArgs>(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<DXPropertyEditor>())
// {
// editor.ControlCreated += new EventHandler<EventArgs>(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<EventArgs>(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; };
}