windowsforms-404225-ui-templates-user-controls-master-detail-grid-views.md
The Master-Detail View template (EmployeesMasterDetailSimple) is a predesigned side-by-side master-detail UI to display and edit employee/contact information.
Note
The EmployeesMasterDetail template is a counterpart of the EmployeesMasterDetailSimple template with support for MVVM architecture.
The Employee Master-Detail UI template is a User Control. It incorporates the following DevExpress WinForms UI controls and services:
Add the Employee Master-Detail or Employee Master-Details (MVVM) template to your WinForms project. Locate the UI template in the Toolbox and drop it onto the Form.
Implement the EmployeesMasterDetailSimple.DataLayer.SaveEmployeeFromDatabase method to save employee information to the database.
public static int SaveEmployeeToDataBase(int id, Employee employee, bool isNew) {
if(!isNew) {
/*
* You should save the changes to the database here.
* The 'id' parameter identifies the record.
*/
return id;
}
else {
/*
* You should add a new record to the database here and
* return its unique identifier (ID).
*/
int newEmployeeId = 0;
return newEmployeeId;
}
}
Implement the EmployeesMasterDetailSimple.DataLayer.DeleteEmployeeFromDataBase method to delete employee information from the database.
public static bool DeleteEmployeeFromDataBase(int id, Employee employee) {
string q = $"Do you really want to delete {employee.FullName}?";
if(XtraMessageBox.Show(q, "Employee Deletion", MessageBoxButtons.YesNo) != DialogResult.Yes)
return false;
/*
* You should remove a record from the database here.
* The 'id' parameter identifies the record.
*/
return true;
}
The Employee Details template includes the Employee class (data object).
Required data fields:
Optional data fields: