This example shows how to open a dialog window by clicking the default button of ButtonEdit, embedded in the WPF DXGrid control.
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Documents
Namespace DXGrid_DialogWindow
''' <summary>
''' Interaction logic for Window1.xaml
''' </summary>
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
gridControl1.DataSource = GetData()
End Sub
Private Function GetData() As List(Of GridDataObject)
Dim list As New List(Of GridDataObject)()
list.Add(New GridDataObject() With {.Value1 = "A", .Value2 = 1})
list.Add(New GridDataObject() With {.Value1 = "B", .Value2 = 2})
list.Add(New GridDataObject() With {.Value1 = "C", .Value2 = 3})
Return list
End Function
End Class
Public Class GridDataObject
Private privateValue1 As String
Public Property Value1() As String
Get
Return privateValue1
End Get
Set(ByVal value As String)
privateValue1 = value
End Set
End Property
Private privateValue2 As Integer
Public Property Value2() As Integer
Get
Return privateValue2
End Get
Set(ByVal value As Integer)
privateValue2 = value
End Set
End Property
End Class
End Namespace
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Namespace DXGrid_DialogWindow
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
grid.DataSource = New ProductList()
End Sub
Private Sub ButtonEditSettings_DefaultButtonClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dispatcher.BeginInvoke(New Action(AddressOf ShowWindow))
End Sub
Private Sub ShowWindow()
Dim wind As New Window1()
wind.ShowDialog()
End Sub
End Class
End Namespace
<Window x:Class="DXGrid_DialogWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
<Grid>
<dxg:GridControl Name="grid">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ProductName">
<dxg:GridColumn.EditSettings>
<dxe:ButtonEditSettings DefaultButtonClick="ButtonEditSettings_DefaultButtonClick" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn FieldName="UnitPrice" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Public Class Product
Private privateProductName As String
Public Property ProductName() As String
Get
Return privateProductName
End Get
Set(ByVal value As String)
privateProductName = value
End Set
End Property
Private privateCountry As String
Public Property Country() As String
Get
Return privateCountry
End Get
Set(ByVal value As String)
privateCountry = value
End Set
End Property
Private privateCity As String
Public Property City() As String
Get
Return privateCity
End Get
Set(ByVal value As String)
privateCity = value
End Set
End Property
Private privateUnitPrice As Double
Public Property UnitPrice() As Double
Get
Return privateUnitPrice
End Get
Set(ByVal value As Double)
privateUnitPrice = value
End Set
End Property
Private privateQuantity As Integer
Public Property Quantity() As Integer
Get
Return privateQuantity
End Get
Set(ByVal value As Integer)
privateQuantity = value
End Set
End Property
End Class
Public Class ProductList
Inherits ObservableCollection(Of Product)
Public Sub New()
MyBase.New()
Add(New Product() With {.ProductName = "Chang", .Country = "UK", .City = "Cowes", .UnitPrice = 19, .Quantity = 10})
Add(New Product() With {.ProductName = "Gravad lax", .Country = "Italy", .City = "Reggio Emilia", .UnitPrice = 12.5, .Quantity = 16})
Add(New Product() With {.ProductName = "Ravioli Angelo", .Country = "Brazil", .City = "Rio de Janeiro", .UnitPrice = 19, .Quantity = 12})
Add(New Product() With {.ProductName = "Tarte au sucre", .Country = "Germany", .City = "QUICK-Stop", .UnitPrice = 22, .Quantity = 50})
Add(New Product() With {.ProductName = "Steeleye Stout", .Country = "USA", .City = "Reggio Emilia", .UnitPrice = 18, .Quantity = 20})
Add(New Product() With {.ProductName = "Pavlova", .Country = "Austria", .City = "Graz", .UnitPrice = 21, .Quantity = 52})
Add(New Product() With {.ProductName = "Longlife Tofu", .Country = "USA", .City = "Boise", .UnitPrice = 7.75, .Quantity = 120})
Add(New Product() With {.ProductName = "Alice Mutton", .Country = "Mexico", .City = "México D.F.", .UnitPrice = 21, .Quantity = 15})
Add(New Product() With {.ProductName = "Alice Mutton", .Country = "Canada", .City = "Tsawwassen", .UnitPrice = 44, .Quantity = 16})
End Sub
End Class
<Window x:Class="DXGrid_DialogWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="232" Width="401" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
<Grid>
<dxg:GridControl Name="gridControl1" AutoPopulateColumns="True" >
<dxg:GridControl.View>
<dxg:TableView />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
using System;
using System.Windows;
namespace DXGrid_DialogWindow {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
grid.DataSource = new ProductList();
}
private void ButtonEditSettings_DefaultButtonClick(object sender, RoutedEventArgs e) {
Dispatcher.BeginInvoke(new Action(ShowWindow));
}
void ShowWindow() {
Window1 wind = new Window1();
wind.ShowDialog();
}
}
}
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class Product {
public string ProductName { get; set; }
public string Country { get; set; }
public string City { get; set; }
public double UnitPrice { get; set; }
public int Quantity { get; set; }
}
public class ProductList : ObservableCollection<Product> {
public ProductList()
: base() {
Add(new Product() { ProductName = "Chang", Country = "UK", City = "Cowes", UnitPrice = 19, Quantity = 10 });
Add(new Product() { ProductName = "Gravad lax", Country = "Italy", City = "Reggio Emilia", UnitPrice = 12.5, Quantity = 16 });
Add(new Product() { ProductName = "Ravioli Angelo", Country = "Brazil", City = "Rio de Janeiro", UnitPrice = 19, Quantity = 12 });
Add(new Product() { ProductName = "Tarte au sucre", Country = "Germany", City = "QUICK-Stop", UnitPrice = 22, Quantity = 50 });
Add(new Product() { ProductName = "Steeleye Stout", Country = "USA", City = "Reggio Emilia", UnitPrice = 18, Quantity = 20 });
Add(new Product() { ProductName = "Pavlova", Country = "Austria", City = "Graz", UnitPrice = 21, Quantity = 52 });
Add(new Product() { ProductName = "Longlife Tofu", Country = "USA", City = "Boise", UnitPrice = 7.75, Quantity = 120 });
Add(new Product() { ProductName = "Alice Mutton", Country = "Mexico", City = "México D.F.", UnitPrice = 21, Quantity = 15 });
Add(new Product() { ProductName = "Alice Mutton", Country = "Canada", City = "Tsawwassen", UnitPrice = 44, Quantity = 16 });
}
}
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
namespace DXGrid_DialogWindow {
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
gridControl1.DataSource = GetData();
}
private List<GridDataObject> GetData() {
List<GridDataObject> list = new List<GridDataObject>();
list.Add(new GridDataObject() { Value1 = "A", Value2 = 1 });
list.Add(new GridDataObject() { Value1 = "B", Value2 = 2 });
list.Add(new GridDataObject() { Value1 = "C", Value2 = 3 });
return list;
}
}
public class GridDataObject {
public string Value1 { get; set; }
public int Value2 { get; set; }
}
}