Skip to main content

CRUD Operations in a Data-Bound Data Grid View for .NET MAUI

  • 3 minutes to read

The DevExpress .NET MAUI Suite ships with built-in record view/edit forms and comprehensive API that help you integrate CRUD (Create-Read-Update-Delete) operations into a data-bound DataGridView. These built-in forms automatically generate data editors according to source item properties. You can customize built-in view/edit forms or create custom forms.

DevExpress DataGridView for MAUI - CRUD app demo

Watch Video: .NET MAUI CRUD — Generated Detail Views, Navigation, Client-Side & Database Constraints Validation

Show Default Forms to Display, Create, and Edit Items

The following methods and commands allow you to invoke built-in view/edit forms:

ShowDetailForm / DataGridViewCommands.ShowDetailForm
Invokes the built-in form that displays detail information about a row source item with the specified handle.
ShowDetailNewItemForm / DataGridViewCommands.ShowDetailNewItemForm
Invokes the built-in form that allows you to create a new item, specify its properties and add it to the source.
ShowDetailEditForm / DataGridViewCommands.ShowDetailEditForm
Invokes the built-in form that allows you to edit an item’s data.

For more information, refer to the following help topic: Invoke CRUD Forms.

Customize View/Edit Forms and Create Custom Forms

The following API members allow you to customize built-in forms and implement custom forms:

DetailFormTemplate
Specifies a custom view form that shows detail information about a source item.
DetailNewItemFormTemplate
Specifies a custom edit form that allows you to add a new source item, and customize its options.
DetailEditFormTemplate
Specifies a custom edit form that allows you to modify source item data.
DetailFormShowing
Occurs before a view/edit form appears, and allows you to customize form settings.
CreateDetailFormViewModel

Occurs before a form is invoked, and allows you to create data items with your parameters or customize DetailFormViewModel settings. Depending on the customized form type, use a DetailFormViewModel or DetailEditFormViewModel object. The following list contains main view model APIs:

For more information, refer to the following help topic: Customize CRUD Forms.

Validate and Save Data

Handle the ValidateAndSave event to validate input values and commit them to the data source.

If you use the DataFormView component to implement detail forms, you can use its built-in validation mechanisms.

For more information about data validation, refer to the following help topic: Validate and Save Data.

Delete Items

The following API members allow you to remove items from the source:

DataGridView.DeleteRow
Accepts a row handle and deletes the corresponding item from the DataGridView.
DetailFormViewModelBase.Delete
Deletes the edited item from the DataGridView.
DetailFormViewModelBase.DeleteCommand
The command that deletes the edited item from the DataGridView.
See Also