Пример #1
0
        protected override object QueryResultValue()
        {
            string currentValue = String.Empty;

            try {
                IList list = ListBindingHelper.GetList(this.OwnerEdit.Properties.DataSource) as IList;
                PropertyDescriptorCollection pdc = ListBindingHelper.GetListItemProperties(this.OwnerEdit.Properties.DataSource);
                PropertyDescriptor           pd  = pdc[this.OwnerEdit.Properties.Columns[this.OwnerEdit.Properties.AutoSearchColumnIndex].FieldName];
                currentValue = pd.GetValue(list[selectedRowIndex]).ToString();
            } catch { }
            if (!this.OwnerEdit.Properties.CaseSensitiveSearch)
            {
                currentValue = currentValue.ToLower();
                this.IncrementalSearchText = this.IncrementalSearchText.ToLower();
            }
            if (this.IncrementalSearchText == "" || currentValue.StartsWith(this.IncrementalSearchText))
            {
                this.IncrementalSearchText = "";
                return(base.QueryResultValue());
            }
            else
            {
                this.IncrementalSearchText = "";
                return(base.QueryOldEditValue());
            }
        }
Пример #2
0
    public static void Bind(this DataGridView view, object dataSource, string dataMember = "", Func <PropertyDescriptor, DataGridViewColumn> columnFactory = null)
    {
        var columns    = new List <DataGridViewColumn>();
        var properties = ListBindingHelper.GetListItemProperties(dataSource, dataMember, null);

        for (int i = 0; i < properties.Count; i++)
        {
            var property = properties[i];
            if (!property.IsBrowsable)
            {
                continue;
            }
            var column = (columnFactory != null ? columnFactory(property) : null) ?? DefaultColumnFactory(property.PropertyType);
            if (column == null)
            {
                continue;
            }
            column.DataPropertyName = property.Name;
            column.Name             = property.Name;
            column.HeaderText       = !string.IsNullOrEmpty(property.DisplayName) ? property.DisplayName : property.Name;
            column.ValueType        = property.PropertyType;
            column.ReadOnly         = property.IsReadOnly;
            columns.Add(column);
        }
        view.DataSource = null;
        view.Columns.Clear();
        view.AutoGenerateColumns = false;
        view.Columns.AddRange(columns.ToArray());
        view.DataMember = dataMember;
        view.DataSource = dataSource;
    }
Пример #3
0
        private void radGridView1_UserDeletedRow(object sender, GridViewRowEventArgs e)
        {
            GridViewRowInfo[] rows = e.Rows;
            for (int i = 0; i < (int)rows.Length; i++)
            {
                GridViewRowInfo row = rows[i];
                if (row.HierarchyLevel != 0)
                {
                    GridViewRelation             relation         = this.radGridView1.Relations.Find(row.ViewTemplate.Parent, row.ViewTemplate);
                    GridViewRowInfo              parentRow        = row.Parent as GridViewRowInfo;
                    PropertyDescriptorCollection parentProperties = ListBindingHelper.GetListItemProperties(parentRow.DataBoundItem);
                    PropertyDescriptor           childDescriptor  = parentProperties.Find(relation.ChildColumnNames[0], true);
                    if (childDescriptor != null)
                    {
                        IList children = childDescriptor.GetValue(parentRow.DataBoundItem) as IList;
                        if (children != null)
                        {
                            children.Remove(row.DataBoundItem);
                            row.ViewInfo.Refresh();

                            foreach (var childRow in row.ViewInfo.ChildRows)
                            {
                                childRow.InvalidateRow();
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public void TryDataBinding()
        {
            int i;
            PropertyDescriptorCollection pc = null;

            if (this.DataSource != null)
            {
                pc = ListBindingHelper.GetListItemProperties(this.DataSource);
            }
            if (pc == null)
            {
                CurrencyManager cm = this.DataManager;
                if (cm != null)
                {
                    pc = cm.GetItemProperties();
                }
            }
            if (pc == null)
            {
                pc = ListBindingHelper.GetListItemProperties(this.Items);
            }
            if (pc != null)
            {
                m_ColumnNamesAll = new string[pc.Count];
                for (i = 0; i < m_ColumnNamesAll.Length; i++)
                {
                    m_ColumnNamesAll[i] = pc[i].Name.ToLower();
                }
            }
            CheckColumns();
            CheckColumnIndexes();
        }
Пример #5
0
        private void SetProperty(ref PropertyDescriptor property, ref string propertyName, string value)
        {
            if (propertyName != value)
            {
                if (value == null)
                {
                    DataMember   = string.Empty;
                    propertyName = string.Empty;
                }
                else
                {
                    var    split = value.Split(_dataMemberFieldSeperator);
                    string temp;
                    if (split.Length > 1)
                    {
                        DataMember = split[0];
                        temp       = split[1];
                    }
                    else
                    {
                        DataMember = string.Empty;
                        temp       = value;
                    }
                    propertyName = null;
                    if (DataSource != null && temp != string.Empty)
                    {
                        var propertyDescriptorCollection = ListBindingHelper.GetListItemProperties(DataSource, DataMember, null);
                        if (propertyDescriptorCollection != null)
                        {
                            if (propertyDescriptorCollection.Count == 0)
                            {
                                propertyName = value;
                            }
                            else
                            {
                                property = propertyDescriptorCollection.Find(temp, true);
                                if (property == null && _fieldsToPropertiesTypeDescriptionProvider == null)
                                {
                                    _fieldsToPropertiesTypeDescriptionProvider = new FieldsToPropertiesTypeDescriptionProvider(propertyDescriptorCollection[0].ComponentType, BindingFlags.Instance | BindingFlags.Public);
                                    TypeDescriptor.AddProvider(_fieldsToPropertiesTypeDescriptionProvider, propertyDescriptorCollection[0].ComponentType);
                                    propertyDescriptorCollection = ListBindingHelper.GetListItemProperties(DataSource, DataMember, null);
                                    property = propertyDescriptorCollection.Find(temp, true);
                                }
                            }
                        }

                        if (property != null)
                        {
                            propertyName = value;
                        }
                    }
                    else
                    {
                        propertyName = value;
                    }
                }
            }
            //  this.ResetData();
        }
 private void InitializeFiltering()
 {
     _properties  = ListBindingHelper.GetListItemProperties(typeof(T));
     _filterTable = new DataTable("FilterTable");
     foreach (PropertyDescriptor property in _properties)
     {
         _filterTable.Columns.Add(property.Name, property.PropertyType);
     }
 }
Пример #7
0
        protected void UpdateDataPropertiesCache()
        {
            if (this.currencyManager == null)
            {
                return;
            }

            this.dataItemProperties = ListBindingHelper.GetListItemProperties(this.currencyManager.List);
        }
Пример #8
0
 public SortedBindingList(IList <T> list) : base(list)
 {
     foreach (var _val in list)
     {
         this._collection.Add(_val);
     }
     this._properties  = ListBindingHelper.GetListItemProperties(typeof(T));
     this.ListChanged += this._listChanged;
 }
Пример #9
0
        public void GetListItemPropertiesTest()
        {
            SimpleItem [] items = new SimpleItem [0];
            PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(items);

            Assert.AreEqual(1, properties.Count, "#A1");
            Assert.AreEqual("Value", properties [0].Name, "#A2");

            List <SimpleItem> items_list = new List <SimpleItem> ();

            properties = ListBindingHelper.GetListItemProperties(items_list);

            Assert.AreEqual(1, properties.Count, "#B1");
            Assert.AreEqual("Value", properties [0].Name, "#B2");

            // Empty arraylist
            ArrayList items_arraylist = new ArrayList();

            properties = ListBindingHelper.GetListItemProperties(items_arraylist);

            Assert.AreEqual(0, properties.Count, "#C1");

            // Non empty arraylist
            items_arraylist.Add(new SimpleItem());
            properties = ListBindingHelper.GetListItemProperties(items_arraylist);

            Assert.AreEqual(1, properties.Count, "#D1");
            Assert.AreEqual("Value", properties [0].Name, "#D2");

            // non list object
            properties = ListBindingHelper.GetListItemProperties(new SimpleItem());

            Assert.AreEqual(1, properties.Count, "#E1");
            Assert.AreEqual("Value", properties [0].Name, "#E2");

            // null value
            properties = ListBindingHelper.GetListItemProperties(null);

            Assert.AreEqual(0, properties.Count, "#F1");

            // ListSource
            properties = ListBindingHelper.GetListItemProperties(new ListSource(true));

            Assert.AreEqual(1, properties.Count, "#G1");
            Assert.AreEqual("Value", properties [0].Name, "#G2");

            // ITypedList
            DataTable table = new DataTable();

            table.Columns.Add("Name", typeof(string));

            properties = ListBindingHelper.GetListItemProperties(table);
            Assert.AreEqual(1, properties.Count, "#H1");
            Assert.AreEqual("Name", properties [0].Name, "#H2");
        }
Пример #10
0
        public PropertyDescriptorCollection GetItemProperties(
            PropertyDescriptor[] listAccessors)
        {
            object list = ListBindingHelper.GetList(this.dataSource);

            if (list is ITypedList && !string.IsNullOrEmpty(this.dataMember))
            {
                return(ListBindingHelper.GetListItemProperties(list, this.dataMember, listAccessors));
            }
            return(ListBindingHelper.GetListItemProperties((object)this.items, listAccessors));
        }
Пример #11
0
        public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            var properties = ListBindingHelper.GetListItemProperties(source, listAccessors);

            if (propertyMapper != null)
            {
                properties = new PropertyDescriptorCollection(properties.Cast <PropertyDescriptor>()
                                                              .Select(propertyMapper).Where(p => p != null).ToArray());
            }
            return(properties);
        }
Пример #12
0
 public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
 {
     if ((listAccessors != null) && (listAccessors.Length >= 1))
     {
         return(ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType));
     }
     if (this.FieldNames != null)
     {
         return(this.FieldNames.GetRowPropertyDescriptors());
     }
     return(null);
 }
Пример #13
0
        private void lookUpEditSubLinea_Properties_PopupFilter(object sender, DevExpress.XtraEditors.Controls.PopupFilterEventArgs e)
        {
            if (string.IsNullOrEmpty(e.SearchText))
            {
                return;
            }
            LookUpEdit edit = sender as LookUpEdit;
            PropertyDescriptorCollection   propertyDescriptors = ListBindingHelper.GetListItemProperties(edit.Properties.DataSource);
            IEnumerable <FunctionOperator> operators           = propertyDescriptors.OfType <PropertyDescriptor>().Select(
                t => new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty(t.Name), new OperandValue(e.SearchText)));

            e.Criteria = new GroupOperator(GroupOperatorType.Or, operators);
            e.SuppressSearchCriteria = true;
        }
Пример #14
0
 protected virtual void Initialize()
 {
     if (this.list is ITypedList)
     {
         this.properties = ((ITypedList)this.list).GetItemProperties((PropertyDescriptor[])null);
         this.name       = ((ITypedList)this.list).GetListName((PropertyDescriptor[])null);
     }
     else if (this.list is IEnumerable)
     {
         this.properties = ListBindingHelper.GetListItemProperties(this.list);
         this.name       = ListBindingHelper.GetListName(this.list, (PropertyDescriptor[])null);
     }
     this.BuildChildren(this);
 }
Пример #15
0
        public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            PropertyDescriptorCollection pdc;

            if (listAccessors != null && listAccessors.Length > 0)
            {
                pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
            }
            else
            {
                pdc = properties;
            }

            return(pdc);
        }
Пример #16
0
        public void UpdateBoundProperties()
        {
            object sourceControl = this.SourceControl;

            this.boundProperties = ListBindingHelper.GetListItemProperties(this.SourceControl);
            PropertyDescriptor[] propertyDescriptorArray = new PropertyDescriptor[this.boundProperties.Count];
            this.boundProperties.CopyTo((Array)propertyDescriptorArray, 0);
            foreach (PropertyDescriptor propertyDescriptor in propertyDescriptorArray)
            {
                if ((object)propertyDescriptor.PropertyType == (object)typeof(IBindingList))
                {
                    this.boundProperties.Remove(propertyDescriptor);
                }
            }
        }
Пример #17
0
        protected override void Initialize()
        {
            this.parentRelationNames = new List <string>();
            this.childRelationNames  = new List <string>();

            DataTable table = this.List as DataTable;

            if (table == null && this.List is DataView)
            {
                table = ((DataView)this.List).Table;
            }

            if (table == null)
            {
                return;
            }

            this.Properties = ListBindingHelper.GetListItemProperties(table);
            this.Name       = table.TableName;

            for (int i = 0; i < table.ChildRelations.Count; i++)
            {
                DataTable childTable = table.ChildRelations[i].ChildTable;

                if (childTable == table)
                {
                    this.ChildRelations.Add(new SelfReferenceRelation(childTable,
                                                                      table.ChildRelations[i].ParentColumns[0].ColumnName,
                                                                      table.ChildRelations[i].ChildColumns[0].ColumnName));
                }
                else
                {
                    DataSetObjectRelation child = new DataSetObjectRelation(childTable);
                    child.Parent = this;

                    for (int j = 0; j < table.ChildRelations[i].ParentColumns.Length; j++)
                    {
                        child.parentRelationNames.Add(table.ChildRelations[i].ParentColumns[j].ColumnName);
                    }

                    for (int j = 0; j < table.ChildRelations[i].ChildColumns.Length; j++)
                    {
                        child.childRelationNames.Add(table.ChildRelations[i].ChildColumns[j].ColumnName);
                    }
                    this.ChildRelations.Add(child);
                }
            }
        }
Пример #18
0
 int System.Collections.IComparer.Compare(object x, object y)
 {
     if (x is ListViewItem && y is ListViewItem)
     {
         return(Compare((ListViewItem)x, (ListViewItem)y));
     }
     if (x.GetType() == y.GetType())
     {
         var props = ListBindingHelper.GetListItemProperties(x);
         if (props != null && props.Count > SortColumn)
         {
             return(AdjustCompareForOrder(ObjectCompare.Compare(props[SortColumn].GetValue(x), props[SortColumn].GetValue(y))));
         }
     }
     return(ObjectCompare.Compare(x, y));
 }
Пример #19
0
        public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            PropertyDescriptorCollection pdc;

            if (null == listAccessors)
            {
                /* Return properties in sort order */
                pdc = _shape;
            }
            else
            {
                /* Return child list shape */
                pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
            }
            return(pdc);
        }
        void MyGridLookUpEdit_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            PropertyDescriptorCollection collection = ListBindingHelper.GetListItemProperties(Properties.GridSelection.Selection);
            PropertyDescriptor           desc       = collection[Properties.DisplayMember];

            foreach (object rv in Properties.GridSelection.Selection)
            {
                if (sb.ToString().Length > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(desc.GetValue(rv).ToString());
            }
            e.DisplayText = sb.ToString();
        }
        public override IList <GridViewRowInfo> GetChildRows(
            GridViewRowInfo parentRow,
            GridViewInfo view)
        {
            List <GridViewRowInfo> gridViewRowInfoList = new List <GridViewRowInfo>();
            PropertyDescriptor     descriptor          = ListBindingHelper.GetListItemProperties(parentRow.DataBoundItem).Find(this.relation.ChildColumnNames[0], true);

            if (descriptor != null)
            {
                List <GridViewRowInfo> cachedChildRows = this.GetCachedChildRows(parentRow.DataBoundItem, descriptor);
                IEnumerable            enumerable      = descriptor.GetValue(parentRow.DataBoundItem) as IEnumerable;
                if (enumerable != null)
                {
                    PropertyDescriptorCollection listItemProperties = ListBindingHelper.GetListItemProperties((object)enumerable);
                    int num = 0;
                    foreach (object obj in enumerable)
                    {
                        GridViewRowInfo childRowInfo = this.GetChildRowInfo(cachedChildRows, num++);
                        ((IDataItem)childRowInfo).DataBoundItem = obj;
                        for (int index = 0; index < this.Template.Columns.Count; ++index)
                        {
                            if (this.Template.Columns[index].IsFieldNamePath)
                            {
                                childRowInfo.Cache[(GridViewColumn)this.Template.Columns[index]] = DataUtils.GetValue(listItemProperties, this.Template.Columns[index].FieldName, obj);
                            }
                            else if (!string.IsNullOrEmpty(this.Template.Columns[index].FieldName))
                            {
                                PropertyDescriptor propertyDescriptor = listItemProperties.Find(this.Template.Columns[index].FieldName, true);
                                if (propertyDescriptor != null)
                                {
                                    childRowInfo.Cache[(GridViewColumn)this.Template.Columns[index]] = propertyDescriptor.GetValue(obj);
                                }
                            }
                        }
                        gridViewRowInfoList.Add(childRowInfo);
                    }
                }
                IBindingList index1 = enumerable as IBindingList;
                if (index1 != null)
                {
                    index1.ListChanged           -= new ListChangedEventHandler(this.bindableChildren_ListChanged);
                    index1.ListChanged           += new ListChangedEventHandler(this.bindableChildren_ListChanged);
                    this.rowsBindingLists[index1] = view;
                }
            }
            return((IList <GridViewRowInfo>)gridViewRowInfoList);
        }
        public void StringPropertiesTest()
        {
            var strings = new[] { "one", "two", "a string" };
            var stringWrapperForBinding = strings.CreateStringWrapperForBinding();
            var stringWrapperProperties = ListBindingHelper.GetListItemProperties(stringWrapperForBinding);

            Assert.AreEqual(1, stringWrapperProperties.Count);
            Assert.AreEqual(typeof(string), stringWrapperProperties[0].PropertyType);
            //stringWrapperForBinding.ShowInGrid(null);
            //strings.ShowInGrid(null);

            //TypeDescriptor.AddProvider(new StringTypeDescriptorProvider(typeof(string)), typeof(string));
            //var stringProperties = ListBindingHelper.GetListItemProperties(strings);
            //Assert.AreEqual(1, stringProperties.Count);
            //Assert.AreEqual(typeof(string), stringProperties[0].PropertyType);
            //strings.ShowInGrid(null);
        }
Пример #23
0
        /// <summary>
        /// Parses a formatted value from the editing control.
        /// This works by matching the editing control's text against the
        /// display values for the list items.
        /// </summary>
        /// <param name="formattedValue"></param>
        /// <param name="cellStyle"></param>
        /// <param name="formattedValueTypeConverter"></param>
        /// <param name="valueTypeConverter"></param>
        /// <returns></returns>
        public override object ParseFormattedValue(object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter)
        {
            if (DataSource != null)
            {
                object listItem = null;
                Func <object, String> dispFormatter;

                if (!String.IsNullOrEmpty(DisplayMember))
                {
                    PropertyDescriptor pd = ListBindingHelper.GetListItemProperties(DataSource)[DisplayMember];
                    dispFormatter = o => Convert.ToString(pd.GetValue(o));
                }
                else
                {
                    dispFormatter = o => Convert.ToString(o);
                }

                foreach (object item in (IList)ListBindingHelper.GetList(DataSource))
                {
                    if (String.Compare(Convert.ToString(formattedValue), dispFormatter(item), true, CultureInfo.CurrentCulture) == 0)
                    {
                        listItem = item;
                        break;
                    }
                }

                if ((listItem != null) && !(listItem is DBNull))
                {
                    Func <object, object> valueFormatter;

                    if (!String.IsNullOrEmpty(ValueMember))
                    {
                        PropertyDescriptor pd = ListBindingHelper.GetListItemProperties(DataSource)[ValueMember];
                        valueFormatter = o => pd.GetValue(o);
                    }
                    else
                    {
                        valueFormatter = o => o;
                    }

                    return(valueFormatter(listItem));
                }
            }

            return(null);
        }
Пример #24
0
        public virtual PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            PropertyDescriptorCollection pdc = null;

            if (null == listAccessors)
            {
                // Return properties in sort order.
                pdc = properties;
            }
            else
            {
                // Return child list shape.
                pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
            }

            return(pdc);
        }
Пример #25
0
        protected override void PerformDataBinding(IEnumerable data)
        {
            base.PerformDataBinding(data);
            ArrayList arrayList = new ArrayList();
            PropertyDescriptorCollection listItemProperties = ListBindingHelper.GetListItemProperties(data);

            foreach (object obj in data)
            {
                if (this.DataFields != null && this.DataFields.Length == 1 && this.DataFields[0] == "ToString()")
                {
                    arrayList.Add(obj.ToString());
                }
                else
                {
                    Dictionary <string, object> dictionary = new Dictionary <string, object>();
                    foreach (object obj2 in listItemProperties)
                    {
                        PropertyDescriptor propertyDescriptor = (PropertyDescriptor)obj2;
                        if (this.DataFields == null || this.DataFields.Length <= 0 || this.DataFields.Contains(propertyDescriptor.Name))
                        {
                            object value = propertyDescriptor.GetValue(obj);
                            if (value != null)
                            {
                                if (ListSource.knownTypes.Contains(value.GetType()))
                                {
                                    dictionary[propertyDescriptor.Name] = value;
                                }
                                else
                                {
                                    dictionary[propertyDescriptor.Name] = value.ToString();
                                }
                            }
                            else
                            {
                                dictionary[propertyDescriptor.Name] = null;
                            }
                        }
                    }
                    arrayList.Add(dictionary);
                }
            }
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            this.JsonData = javaScriptSerializer.Serialize(arrayList);
        }
        void getTypeInfo(object sender, GetTypeInfoEventArgs e)
        {
            GetSourceEventArgs           getQueryArgs      = (GetSourceEventArgs)e.Tag;
            PropertyDescriptorCollection sourceDescriptors = ListBindingHelper.GetListItemProperties(e.ListServerSource);

            if (getQueryArgs.Query == null)
            {
                e.TypeInfo = new TypeInfoNoSource(this.DesignTimeElementType);
            }
            else if (getQueryArgs.AreSourceRowsThreadSafe)
            {
                e.TypeInfo = new TypeInfoThreadSafe(sourceDescriptors);
            }
            else
            {
                e.TypeInfo = new TypeInfoProxied(sourceDescriptors, this.DesignTimeElementType);
            }
        }
Пример #27
0
        public void GetListItemPropertiesTest2()
        {
            ListContainer list_container = new ListContainer();
            PropertyDescriptorCollection list_properties = TypeDescriptor.GetProperties(list_container);
            PropertyDescriptor           property        = list_properties ["List"];

            PropertyDescriptorCollection property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                                                 new PropertyDescriptor [] { property });

            Assert.AreEqual(1, property_coll.Count, "#A1");
            Assert.AreEqual("Value", property_coll [0].Name, "#A2");

            // Empty property descriptor array
            // Returns list_container properties, since it's not a list
            property_coll = ListBindingHelper.GetListItemProperties(list_container, new PropertyDescriptor [0]);
            Assert.AreEqual(2, property_coll.Count, "#B1");

            // Non list property
            // Returns the propeties of the type of that property
            property      = list_properties ["NonList"];
            property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                    new PropertyDescriptor [] { property });
            Assert.AreEqual(1, property_coll.Count, "#C1");
            Assert.AreEqual("Value", property_coll [0].Name, "#C2");

            // Pass two properties
            property = list_properties ["List"];
            PropertyDescriptor property2 = list_properties ["NonList"];

            property_coll = ListBindingHelper.GetListItemProperties(list_container,
                                                                    new PropertyDescriptor [] { property2, property });
            Assert.AreEqual(0, property_coll.Count, "#D1");

            //
            // Third overload - doble re-direction
            //
            SuperContainer super_container = new SuperContainer();

            property = list_properties ["List"];

            property_coll = ListBindingHelper.GetListItemProperties(super_container, "ListContainer",
                                                                    new PropertyDescriptor [] { property });
            Assert.AreEqual(1, property_coll.Count, "#E1");
        }
Пример #28
0
        public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            var itemType = GetItemType();

            PropertyDescriptorCollection pdc;

            if (listAccessors != null && listAccessors.Length > 0)
            {
                // Return child list shape.
                pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
            }
            else
            {
                // Return properties in sort order.
                pdc = ListBindingHelper.GetListItemProperties(itemType);
            }

            return(pdc);
        }
        void gridSelection__SelectionChanged(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            PropertyDescriptorCollection collection = ListBindingHelper.GetListItemProperties(GridSelection.Selection);
            PropertyDescriptor           desc       = collection[DisplayMember];

            foreach (object rv in GridSelection.Selection)
            {
                if (sb.ToString().Length > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(desc.GetValue(rv).ToString());
            }
            if (OwnerEdit != null)
            {
                OwnerEdit.Text = sb.ToString();
            }
        }
Пример #30
0
        public override IList <RadTreeNode> GetNodes(RadTreeNode parent)
        {
            if (parent is RadTreeViewElement.RootTreeNode)
            {
                for (int i = 0; i < this.TreeView.ListSource.Count; i++)
                {
                    this.TreeView.ListSource[i].Parent = parent;
                }

                return(this.TreeView.ListSource);
            }

            if (ResolveDescriptors(parent.BoundIndex + 1, parent.DataBoundItem))
            {
                List <RadTreeNode> nodes    = new List <RadTreeNode>();
                IEnumerable        children = this.TreeView.BoundDescriptors[parent.BoundIndex + 1].ChildDescriptor.GetValue(parent.DataBoundItem) as IEnumerable;
                if (children != null)
                {
                    if (parent.BoundIndex + 1 < this.displayMembers.Length)
                    {
                        PropertyDescriptorCollection properties = ListBindingHelper.GetListItemProperties(children);
                        this.TreeView.BoundDescriptors[parent.BoundIndex + 1].DisplayDescriptor = properties.Find(this.displayMembers[parent.BoundIndex + 1], true);
                    }

                    foreach (object item in children)
                    {
                        RadTreeNode node = this.TreeView.CreateNewNode();
                        ((IDataItem)node).DataBoundItem = item;
                        node.Parent     = parent;
                        node.BoundIndex = parent.BoundIndex + 1;
                        nodes.Add(node);
                    }

                    parent.NodesLoaded = true;
                }

                return(nodes);
            }

            return(RadTreeNodeCollection.Empty);
        }