2
Answers

sorting dynamic changing data

pedro lator

pedro lator

8y
205
1
on dapfor wpf gridcontrol, data may change while the application is running. Just like the way price changes in financial market. How will I be able to sort the data.
Answers (2)
0
life guru
NA 4 2 8y

This code will help you as you use dapfor wpf gridcontrol.

C#

class Product : INotifyPropertyChanged

{

private readonly string _name;

private double _price;

public Product(string name)

{

_name = name;

}

public string Name { get { return _name; } }

public double Price

{

get { return _price; }

set

{

if(_price != value)

{

_price = value;

if(PropertyChanged != null)

{

PropertyChanged(this, new PropertyChangedEventArgs("Price"));

}

}

}

}

public event PropertyChangedEventHandler PropertyChanged;

}

public void Populate(GridControl grid)

{

//Create some products

Product product1 = new Product("Product 1");

Product product2 = new Product("Product 2");

product1.Price = 7;

product2.Price = 9;

//Add them to the grid

grid.Rows.Add(product1);

grid.Rows.Add(product2);

//Sort the content

grid.Headers[0]["Price"].SortDirection = SortDirection.Ascending;

//The grid will move the product1 to the appropriate position

product1.Price = 10;

}

0
Bhuvanesh Mohankumar
NA 14.4k 1.3m 8y

As I said earlier, please try this link

http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part9

Mark as answer, if helpful.