public void Update() { this.context.Clear(); if (!this.treeView.ListSource.IsDataBound) { return; } //if (this.treeView.IsValidParentMember) //{ // TreeNodeDescriptor descriptor = new TreeNodeDescriptor(); // descriptor.Descriptor = this.treeView.ListSource.BoundProperties[this.treeView.ParentBoundIndex]; // descriptor.Index = this.treeView.ParentBoundIndex; // descriptor.Descending = false; // this.context.Add(descriptor); //} for (int i = 0; i < this.treeView.SortDescriptors.Count; i++) { SortDescriptor sd = this.treeView.SortDescriptors[i]; PropertyDescriptor pd = this.treeView.ListSource.BoundProperties.Find(sd.PropertyName, true); if (pd != null) { TreeNodeDescriptor descriptor = new TreeNodeDescriptor(); descriptor.Descriptor = pd; descriptor.Index = this.treeView.ListSource.BoundProperties.IndexOf(pd); descriptor.Descending = (sd.Direction == ListSortDirection.Descending); this.context.Add(descriptor); } } }
private bool ResolveDescriptors(int level, object dataBoundItem) { if (level < this.childMembers.Length) { if (level < this.TreeView.BoundDescriptors.Count) { return(true); } PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(dataBoundItem); PropertyDescriptor childDescriptor = properties.Find(this.childMembers[level], true); if (childDescriptor != null) { TreeNodeDescriptor treeNodeDescriptor = new TreeNodeDescriptor(); treeNodeDescriptor.ChildDescriptor = childDescriptor; this.TreeView.BoundDescriptors.Add(treeNodeDescriptor); return(true); } return(false); } return(false); }
private void InitilizeRelationBinding() { ClearRelationBinding(); for (int i = 0; i < this.TreeView.RelationBindings.Count; i++) { RelationBinding relation = this.TreeView.RelationBindings[i]; relation.PropertyChanged += new PropertyChangedEventHandler(relation_PropertyChanged); CurrencyManager cm = null; if (relation.DataSource is BindingSource) { cm = ((BindingSource)relation.DataSource).CurrencyManager; } if (cm == null && relation.DataSource != null) { cm = this.TreeView.BindingContext[relation.DataSource, relation.DataMember] as CurrencyManager; } if (cm != null) { WireEvents(cm); PropertyDescriptorCollection properties = null; if (i == 0) { if (((ICurrencyManagerProvider)this.TreeView.ListSource).CurrencyManager != null) { properties = ((ICurrencyManagerProvider)this.TreeView.ListSource).CurrencyManager.GetItemProperties(); } } else { properties = this.relationBindings[i - 1].GetItemProperties(); } PropertyDescriptor descriptor = null; if (properties != null) { descriptor = properties.Find(relation.ParentMember, true); } if (descriptor == null) { return; } this.TreeView.BoundDescriptors[i].ParentDescriptor = descriptor; properties = cm.GetItemProperties(); TreeNodeDescriptor relationDescriptor = new TreeNodeDescriptor(); string childPath = relation.ChildMember.Split('\\')[0]; string[] names = childPath.Split('.'); PropertyDescriptor pd = properties.Find(names[0], true); if (pd != null) { if (names.Length > 1) { relationDescriptor.SetChildDescriptor(pd, childPath); } else { relationDescriptor.ChildDescriptor = pd; } } string valuePath = relation.ValueMember.Split('\\')[0]; names = valuePath.Split('.'); pd = properties.Find(names[0], true); if (pd != null) { if (names.Length > 1) { relationDescriptor.SetValueDescriptor(pd, valuePath); } else { relationDescriptor.ValueDescriptor = pd; } } string displayPath = relation.DisplayMember.Split('\\')[0]; names = displayPath.Split('.'); pd = properties.Find(names[0], true); if (pd != null) { if (names.Length > 1) { relationDescriptor.SetDisplaytDescriptor(pd, valuePath); } else { relationDescriptor.DisplayDescriptor = pd; } } this.TreeView.BoundDescriptors.Add(relationDescriptor); AvlTree <RadTreeNode> nodes = new AvlTree <RadTreeNode>(new ChildComparer()); this.relationIndex.Add(nodes); this.relationBindings.Add(cm); this.relationLevelLoaded.Add(false); } } }