Domanda

I have a TreeView and a ListBox. Both of them get populated from different DataTables.

The Treeview gets its data from:

 DataTable product_type = new DataTable();
 product_type.Columns.Add(new DataColumn("id_product_type", typeof(int)));
 product_type.Columns.Add(new DataColumn("name", typeof(string)));
 product_type.Columns.Add(new DataColumn("id_parent",typeof(int)));
 DS.Tables.Add(product_type);

The parent child relation:

DS.Relations.Add(new DataRelation("rsParentChild", product_type.Columns["id_product_type"], product_type.Columns["id_parent"]));

So I want to get the id_product_type from the TreeView on SelectedItemChanged and pass it to my listbox, but how do I get the actual value, the int?

È stato utile?

Soluzione

Tht's what you are looking for(i used a dataview to bind the list) :

private void tlstView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            int new_value =(int)((DataRowView)e.NewValue).Row["id_product_type"];
        }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top