c# - WPF DataGrid: check certain columns and update -



c# - WPF DataGrid: check certain columns and update -

in wpf application have datagrid. example, 1 in picture:

in first row, name a0 , value 0x12 (hexadecimal), lets phone call a0[value]. need create sure that: a0[value] < a1[value] < a2[value]. b0[value] < b1[value] < b2[value], , c0[value] < c1[value]. can't depend on fact name first column , value 4th column. know name column have values a0,a1,a2,b0,b1,b2,c0,c1 don't know in order. , create more complicated, if example, a0[value] > a1[value], need alter a1[value] a1[value]=a0[value]. need help.

in wpf, don't manipulate ui elements. instead, manipulate info elements. therefore, problem becomes whole lot easier if info bind collection datagrid.itemssource property , manipulate info before display it:

<datagrid itemssource="{binding items}" ... />

you should represent info custom classes (that implement inotifypropertychanged interface) because makes much easier. example, can see class (let's name item) should have 4 properties: name, somecol, blah , value. collection should of type observablecollection<item>:

public observablecollection<item> items { { homecoming items; } set { items = value; notifypropertychanged("items"); } }

now need sort data. there many different ways of achieving , differing levels of complication, using linq can help. first, want order info first letter in name column, represented name property in class , need sort items value property. can't check right now, should trick, or somewhere close:

using system.linq; items = new observablecollection<item>(items.orderby(i => i.name.firstordefault()). thenby(i => i.value))

c# wpf datagrid wpfdatagrid

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -