How can I hide the toolbar that appears in the DetailPropertyEditor when it is used as the editor for a reference property?
We have closed this ticket because another page addresses its subject:
How to hide the toolbar of a nested list viewDisable ToolBar From DetailPropertyEditor
Answers approved by DevExpress Support
Hello Kivash,
To accomplish this task, access the nested frame via the DetailPropertyEditor.Frame property, cast its template to the ISupportActionsToolbarVisibility interface and use the ISupportActionsToolbarVisibility.SetVisible method. Here is an example:
C#public class HideToolbarsController : ViewController<DetailView> {
protected override void OnActivated() {
base.OnActivated();
foreach (DetailPropertyEditor detailPropertyEditor in View.GetItems<DetailPropertyEditor>()) {
detailPropertyEditor.ControlCreated += new EventHandler<EventArgs>(detailPropertyEditor_ControlCreated);
}
}
void detailPropertyEditor_ControlCreated(object sender, EventArgs e) {
Frame nestedFrame = ((DetailPropertyEditor)sender).Frame;
if (nestedFrame != null && nestedFrame.Template is ISupportActionsToolbarVisibility) {
((ISupportActionsToolbarVisibility)nestedFrame.Template).SetVisible(false);
}
}
protected override void OnDeactivated() {
base.OnDeactivated();
foreach (DetailPropertyEditor detailPropertyEditor in View.GetItems<DetailPropertyEditor>()) {
detailPropertyEditor.ControlCreated -= new EventHandler<EventArgs>(detailPropertyEditor_ControlCreated);
}
}
}
Visual BasicPublic Class HideToolbarsController
Inherits ViewController(Of DetailView)
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
For Each detailPropertyEditor As DetailPropertyEditor In View.GetItems(Of DetailPropertyEditor)()
AddHandler detailPropertyEditor.ControlCreated, AddressOf detailPropertyEditor_ControlCreated
Next detailPropertyEditor
End Sub
Private Sub detailPropertyEditor_ControlCreated(ByVal sender As Object, ByVal e As EventArgs)
Dim nestedFrame As Frame = (CType(sender, DetailPropertyEditor)).Frame
If nestedFrame IsNot Nothing AndAlso TypeOf nestedFrame.Template Is ISupportActionsToolbarVisibility Then
CType(nestedFrame.Template, ISupportActionsToolbarVisibility).SetVisible(True)
End If
End Sub
Protected Overrides Sub OnDeactivated()
MyBase.OnDeactivated()
For Each detailPropertyEditor As DetailPropertyEditor In View.GetItems(Of DetailPropertyEditor)()
RemoveHandler detailPropertyEditor.ControlCreated, AddressOf detailPropertyEditor_ControlCreated
Next detailPropertyEditor
End Sub
End Class