Skip to content

Commit 35b1359

Browse files
Commit the changes
1 parent bf2218d commit 35b1359

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

SfDataGridDemo/Form1.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ public partial class Form1 : Form
2121
public Form1()
2222
{
2323
InitializeComponent();
24+
2425
orderInfo = new OrderInfoCollection();
26+
2527
sfDataGrid1.AutoGenerateColumns = false;
2628
sfDataGrid1.SelectionMode = GridSelectionMode.Multiple;
2729
sfDataGrid1.DataSource = orderInfo.Orders;
30+
2831
sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "Order ID", AllowEditing = false });
2932
sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerID", HeaderText = "Customer ID" , AllowEditing = true});
3033
sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerName", HeaderText = "Name", AllowEditing = false });
3134
sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "Country", HeaderText = "Country" , AllowEditing = true });
3235
sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "ShipCity", HeaderText = "Ship City" , AllowEditing = false });
36+
37+
//Event subscription
3338
sfDataGrid1.SelectionChanging += OnSelectionChanging;
3439
}
3540

41+
//Event customization
3642
private void OnSelectionChanging(object sender, SelectionChangingEventArgs e)
3743
{
3844
var dataGrid = (sender as SfDataGrid);

SfDataGridDemo/Model/Model.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class OrderInfo : INotifyPropertyChanged
1414
string country;
1515
string customerName;
1616
string shipCity;
17+
1718
public int OrderID
1819
{
1920
get { return orderID; }
@@ -23,6 +24,7 @@ public int OrderID
2324
OnPropertyChanged("OrderID");
2425
}
2526
}
27+
2628
public string CustomerID
2729
{
2830
get { return customerId; }
@@ -32,6 +34,7 @@ public string CustomerID
3234
OnPropertyChanged("CustomerID");
3335
}
3436
}
37+
3538
public string CustomerName
3639
{
3740
get { return customerName; }
@@ -41,6 +44,7 @@ public string CustomerName
4144
OnPropertyChanged("CustomerName");
4245
}
4346
}
47+
4448
public string Country
4549
{
4650
get { return country; }
@@ -50,6 +54,7 @@ public string Country
5054
OnPropertyChanged("Country");
5155
}
5256
}
57+
5358
public string ShipCity
5459
{
5560
get { return shipCity; }
@@ -75,6 +80,7 @@ public OrderInfo()
7580
}
7681

7782
public event PropertyChangedEventHandler PropertyChanged;
83+
7884
public void OnPropertyChanged(string PropertyName)
7985
{
8086
if (PropertyChanged != null)

SfDataGridDemo/ViewModel/ViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ namespace SfDataGrid_Demo
1111
public class OrderInfoCollection
1212
{
1313
private ObservableCollection<OrderInfo> _orders;
14+
1415
public ObservableCollection<OrderInfo> Orders
1516
{
1617
get { return _orders; }
1718
set { _orders = value; }
1819
}
20+
1921
public OrderInfoCollection()
2022
{
2123
_orders = new ObservableCollection<OrderInfo>();
2224
this.GenerateOrders();
2325
}
26+
2427
private void GenerateOrders()
2528
{
2629
_orders.Add(new OrderInfo(1001, "Maria", "Germany", "ALFKI", "Berlin"));

0 commit comments

Comments
 (0)