Skip to main content

DataGridView.ShowDetailNewItemForm(Boolean) Method

Invokes a form used to create a new Data Grid View item.

Namespace: DevExpress.Maui.DataGrid

Assembly: DevExpress.Maui.DataGrid.dll

NuGet Package: DevExpress.Maui.DataGrid

Declaration

public void ShowDetailNewItemForm(
    bool animated = false
)

Optional Parameters

Name Type Default Description
animated Boolean False

Specifies whether animation effects apply to the edit form when it is invoked.

Remarks

The following example shows how to invoke the default Add new item form page:

DevExpress DataGridView for MAUI - Default form for creating new item

public MainPage() {
    InitializeComponent();
    BindingContext = new TestOrderRepository();
}
private void Button_Clicked(object sender, EventArgs e) {
    grid.ShowDetailNewItemForm();
}    
Show BindingContext implementation
using System.ComponentModel;
namespace GridCrudTestApp;
public abstract class OrderRepository {
   readonly BindingList<Order> orders;
   public OrderRepository() {
       this.orders = new BindingList<Order>();
   }
   public BindingList<Order> Orders {
       get { return orders; }
   }
}
public class TestOrderRepository : OrderRepository {
   const int orderCount = 20;
   readonly Random random;
   public TestOrderRepository() : base() {
       this.random = new Random((int)DateTime.Now.Ticks);
       for (int i = 0; i < orderCount; i++)
           Orders.Add(GenerateOrder(i));
   }
   Order GenerateOrder(int number) {
       Order order = new Order(
           new DateTime(2022, 9, 1).AddDays(random.Next(0, 60)),
           number % 3 == 0,
           RandomProduct(),
           random.Next(1, 100),
           (PackagingType)random.Next(Enum.GetNames(typeof(PackagingType)).Length));
       return order;
   }
   ProductName RandomProduct() {
       Array enumValues = Enum.GetValues(typeof(ProductName));
       return (ProductName)enumValues.GetValue(random.Next(enumValues.Length));
   }
}
public class Order : INotifyPropertyChanged {
   ProductName productName;
   DateTime date;
   bool fastDelivery;
   int quantity;
   PackagingType packagingType;
   public Order() {
       this.productName = ProductName.Tofu;
       this.date = DateTime.Today;
       this.fastDelivery = false;
       this.quantity = 0;
       this.packagingType = PackagingType.CardboardBox;
   }
   public Order(DateTime date, bool fastDelivery, ProductName productName, int quantity, PackagingType packagingType) {
       this.productName = productName;
       this.date = date;
       this.fastDelivery = fastDelivery;
       this.quantity = quantity;
       this.packagingType = packagingType;
   }
   public ProductName ProductName {
       get { return productName; }
       set {
           if (productName != value) {
               productName = value;
               RaisePropertyChanged("ProductName");
           }
       }
   }
   public int Quantity {
       get { return quantity; }
       set {
           if (quantity != value) {
               quantity = value;
               RaisePropertyChanged("Quantity");
           }
       }
   }
   public DateTime Date {
       get { return date; }
       set {
           if (date != value) {
               date = value;
               RaisePropertyChanged("Date");
           }
       }
   }
   public bool FastDelivery {
       get { return fastDelivery; }
       set {
           if (fastDelivery != value) {
               fastDelivery = value;
               RaisePropertyChanged("FastDelivery");
           }
       }
   }
   public PackagingType PackagingType {
       get { return packagingType; }
       set {
           if (packagingType != value) {
               packagingType = value;
               RaisePropertyChanged("PackagingType");
           }
       }
   }
   public event PropertyChangedEventHandler PropertyChanged;
   protected void RaisePropertyChanged(string name) {
       if (PropertyChanged != null)
           PropertyChanged(this, new PropertyChangedEventArgs(name));
   }
}
public enum PackagingType { CardboardBox, CorrugatedBox, ClingFilm, PlasticBox, Chipboard }
public enum ProductName { Tofu, Chocolade, Ikura, Chai, BostonCrabMeat, RavioliAngelo, IponCoffee, QuesoCabrales }

For more information, refer to the following help topic: Show Built-In Forms to Display, Create, and Edit Items.

See Also