Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

NewObjectViewController Class

Represents a ViewController descendant that contains the New Action.

Namespace: DevExpress.ExpressApp.SystemModule

Assembly: DevExpress.ExpressApp.v19.2.dll

Declaration

public class NewObjectViewController :
    ViewController,
    IComparer<ChoiceActionItem>,
    IModelExtender

Remarks

The NewObjectViewController is intended for presenting the New Action.

In a Windows Forms application:

WinNewObjectViewController_New

In an ASP.NET application:

WebNewObjectViewController_NewAction

WebNewObjectViewController_NewRootObjectAction

For details on the New Action, refer to the description of the NewObjectViewController.NewObjectAction property that provides access to this Action.

To customize the default behavior of the New Action, you can inherit from this Controller, or subscribe to its events. In addition, you can access the Action to modify its behavior.

If you need to inherit from the NewObjectViewController, the following protected virtual methods are available:

Method

When is it called?

Description

OnObjectCreating

Invoked as a result of calling the New method before creating a new object of the chosen type.

Raises the NewObjectViewController.ObjectCreating event.

OnCustomAddObjectToCollection

Invoked as a result of calling the New method after the new object has been created, but not added to the current object collection.

Raises the NewObjectViewController.CustomAddObjectToCollection event.

OnObjectCreated

Invoked as a result of calling the New method after the new object has been created and added to the current object collection. If the ObjectCreatedEventArgs.ShowDetailView property is set to true, a Detail View with the new object is invoked after calling this method.

Raises the NewObjectViewController.ObjectCreated event.

New

When the New Action’s SingleChoiceAction.Execute event is raised.

  • Creates a new object using ObjectCreatedEventArgs‘ properties.
  • Adds the new object to the collection source of the Controller’s current List View. If the current View represents a Detail View, the object is added to the List View from which the Detail View has been added. If you need to add the new object in a custom way, handle the NewObjectViewController.CustomAddObjectToCollection event and set the handler’s ProcessNewObjectEventArgs.Handled parameter to false.
  • Shows a Detail View with the new object, if the NewObjectViewController.ObjectCreating event handler’s ObjectCreatingArgs.ShowDetailView parameter is set to true.

UpdateActionState

Called when the NewObjectViewController is activated. In addition, it is called when the current ListView’s CollectionSource is changed, and when the current View’s View.AllowNew property is changed. In this Controller’s platform-specific descendants, this method is overridden to populate the New Action’s ChoiceActionBase.Items collection.

 

Public members are described individually in the documentation.

Note

Inherit from the DevExpress.ExpressApp.Win.SystemModule.WinNewObjectViewController or DevExpress.ExpressApp.Web.SystemModule.WebNewObjectViewController class, if you need to implement a UI-specific behavior.

To ascertain whether the Controller is active, use the Controller.Active property (see How to: Detect a Lookup List View in Code). If you need to know the reason for its deactivation or activation at runtime, use the DiagnosticInfo Action.

Information on the NewObjectViewController and its New Action is available in the Application Model. To access it, use the Model Editor.

See Also