Class FieldDescriptorCollection
A collection of FieldDescriptor fields with mapping information to columns of the underlying datasource. An instance of this collection is returned by the Fields property of a TableDescriptor.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Grouping
Assembly: Syncfusion.Grouping.Base.dll
Syntax
public class FieldDescriptorCollection : IDisposable, IList, ICollection, IEnumerable, IInsideCollectionEditorProperty, ICloneable, ICustomTypeDescriptor
Constructors
FieldDescriptorCollection()
Initializes a new empty collection.
Declaration
public FieldDescriptorCollection()
FieldDescriptorCollection(TableDescriptor)
Initializes a new instance FieldDescriptorCollection collection and attaches it to a TableDescriptor.
Declaration
public FieldDescriptorCollection(TableDescriptor tableDescriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDescriptor | tableDescriptor | Table Descriptor. |
Fields
Empty
A Read-only and empty collection.
Declaration
public static readonly FieldDescriptorCollection Empty
Field Value
| Type |
|---|
| FieldDescriptorCollection |
Properties
AllowAddRangeChangedWarning
For internal use only. Gets or sets the AllowAddRange property.
Declaration
public static bool AllowAddRangeChangedWarning { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Count
Gets the number of elements contained in the collection. The property also ensures that the collection is in sync with the underlying table if changes have been made to the table or the TableDescriptor.
Declaration
public int Count { get; }
Property Value
| Type |
|---|
| System.Int32 |
Remarks
The method calls EnsureInitialized(Boolean).
ExpandProperties
Gets or sets the ExpandProperties.
Declaration
[Obsolete("Replaced with Engine.ShowNestedPropertiesFields")]
public bool ExpandProperties { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
InsideCollectionEditor
Gets or sets whether the collection is manipulated inside a collection editor.
Declaration
public bool InsideCollectionEditor { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
IsFixedSize
Returns normally False since this collection has no fixed size. Only when it is Read-only, IsFixedSize returns True.
Declaration
public bool IsFixedSize { get; }
Property Value
| Type |
|---|
| System.Boolean |
IsModified
Determines if the collection was modified from its default state.
Declaration
public bool IsModified { get; }
Property Value
| Type |
|---|
| System.Boolean |
IsReadOnly
Determines if the collection is Read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type |
|---|
| System.Boolean |
IsSynchronized
Gets value for IsSynchronized as false.
Declaration
public bool IsSynchronized { get; }
Property Value
| Type |
|---|
| System.Boolean |
Item[Int32]
Gets or sets the element at the zero-based index.
Declaration
public FieldDescriptor this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
Property Value
| Type |
|---|
| FieldDescriptor |
Item[String]
Gets or sets the element with the specified name.
Declaration
public FieldDescriptor this[string name] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Property Value
| Type |
|---|
| FieldDescriptor |
PopulateForeignKeyFields
Gets or sets the PopulateForeignKeyFields values.
Declaration
[Obsolete("Replaced with Engine.ShowRelationFields")]
public bool PopulateForeignKeyFields { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
ShouldPopulate
Gets or sets whether collection should check for changes in engine schema or underlying data source schema when EnsureInitialized gets called.
Declaration
public bool ShouldPopulate { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Version
The version number of this collection. The version is increased each time the collection or an element within the collection is modified. When getting the version, EnsureInitialized(Boolean) is called to ensure the collection is auto-populated if needed.
Declaration
public int Version { get; set; }
Property Value
| Type |
|---|
| System.Int32 |
Methods
Add(FieldDescriptor)
Adds an object to the end of the collection.
Declaration
public int Add(FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor | value | The element to be added to the end of the collection. The value must not be a NULL reference (Nothing in Visual Basic). |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based collection index at which the value has been added. |
Add(String)
Adds an object to the end of the collection.
Declaration
public int Add(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the element to be added to the end of the collection. The value must not be a NULL reference (Nothing in Visual Basic). |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based collection index at which the value has been added. |
AddRange(FieldDescriptor[])
Adds multiple elements at the end of the collection.
Declaration
public void AddRange(FieldDescriptor[] fieldDescriptors)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor[] | fieldDescriptors | The array with elements that should be added to the end of the collection. The array and its elements cannot be NULL references (Nothing in Visual Basic). |
CheckType(Object)
Ensure type correctness when a new element is added to the collection.
Declaration
protected virtual void CheckType(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The newly added object. |
Clear()
Removes all elements from the collection.
Declaration
public void Clear()
Clone()
Creates a copy of the collection and all its elements.
Declaration
public FieldDescriptorCollection Clone()
Returns
| Type | Description |
|---|---|
| FieldDescriptorCollection | A copy of the collection and all its elements. |
Contains(FieldDescriptor)
Determines if the element belongs to this collection.
Declaration
public bool Contains(FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor | value | The Object to locate in the collection. The value can be a NULL reference (Nothing in Visual Basic). |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if item is found in the collection; otherwise, False. |
Remarks
The method ensures that the collection is in sync with the underlying table if changes have been made to the table or the TableDescriptor.
The method calls EnsureInitialized(Boolean).
Contains(String)
Determines if an element with the specified name belongs to this collection.
Declaration
public bool Contains(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the element to locate in the collection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if item is found in the collection; otherwise, False. |
CopyTo(FieldDescriptor[], Int32)
Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
Declaration
public void CopyTo(FieldDescriptor[] array, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor[] | array | The one-dimensional array that is the destination of the elements copied from ArrayList. The array must have zero-based indexing. |
| System.Int32 | index | The zero-based index in array at which copying begins. |
CreateCollection(TableDescriptor, FieldDescriptor[])
Called from InternalClone to create a new collection and attach it to the specified table descriptor and insert the specified fields. The fields have already been cloned.
Declaration
protected virtual FieldDescriptorCollection CreateCollection(TableDescriptor td, FieldDescriptor[] fieldDescriptors)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDescriptor | td | The table descriptor. |
| FieldDescriptor[] | fieldDescriptors | The cloned field descriptors. |
Returns
| Type | Description |
|---|---|
| FieldDescriptorCollection | A new FieldDescriptorCollection. |
Dispose()
Disposes the object and collection items.
Declaration
public void Dispose()
EnableOneTimePopulate()
When called the ShouldPopulate property will be set true temporarily until the next EnsureInitialized call and then be reset again to optimize subsequent lookups. The Engine calls this method when schema changes occurred (PropertyChanged was raised).
Declaration
public void EnableOneTimePopulate()
EnsureInitialized(Boolean)
Ensures the collection is initialized and auto-populates the collection on demand.
Declaration
protected virtual void EnsureInitialized(bool populate)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | populate | True if collection should auto-populate itself based on properties of the underlying data source. |
Equals(Object)
Compares two descriptors.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | Field descriptor to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the descriptors are equal; False otherwise. |
Overrides
GetEnumerator()
Returns an enumerator for the entire collection.
Declaration
public FieldDescriptorCollectionEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| FieldDescriptorCollectionEnumerator | An Enumerator for the entire collection. |
Remarks
Enumerators only allow reading the data in the collection. Enumerators cannot be used to modify the underlying collection.
GetHashCode()
Serves as a hash function.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | Hash code. |
Overrides
IndexOf(FieldDescriptor)
Returns the zero-based index of the occurrence of the element in the collection.
Declaration
public int IndexOf(FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor | value | The element to locate in the collection. The value can be a NULL reference (Nothing in Visual Basic). |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based index of the occurrence of the element within the entire collection, if found; otherwise, -1. |
IndexOf(String)
Searches for the element with the specified name.
Declaration
public int IndexOf(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the element to locate in the collection. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The zero-based index of the occurrence of the element with matching name within the entire collection, if found; otherwise, -1. |
InitializeFrom(FieldDescriptorCollection)
Copies settings from another collection and raises Changing and Changed events if differences to the other collection are detected.
Declaration
public void InitializeFrom(FieldDescriptorCollection other)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptorCollection | other | The source collection. |
Insert(Int32, FieldDescriptor)
Inserts a descriptor element into the collection at the specified index.
Declaration
public void Insert(int index, FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index at which the element should be inserted. |
| FieldDescriptor | value | The element to insert. The value must not be a NULL reference (Nothing in Visual Basic). |
Remarks
The method ensures that the collection is in sync with the underlying table if changes have been made to the table or the TableDescriptor.
IsComplexType(PropertyDescriptor)
Determines if the specified PropertyDescriptor has nested properties.
Declaration
protected virtual bool IsComplexType(PropertyDescriptor pd)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ComponentModel.PropertyDescriptor | pd | The PropertyDescriptor to be checked. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if nested properties are found; False otherwise. |
LoadDefault()
Resets the collection to its default state, auto populates the collection, and marks the collection as modified. Call this method if you want to load the default items for the collection and then modify it (e.g. remove members from the auto-populated list).
Declaration
public void LoadDefault()
Examples
gridGroupingControl1.TableDescriptor.Fields.LoadDefault();
gridGroupingControl1.TableDescriptor.Fields.Remove("MyChildTable.ForeignCategoryID");
Modify()
Marks the collection as modified and avoids auto-population.
Declaration
public void Modify()
OnChanged(ListPropertyChangedEventArgs)
Raises the Changed event.
Declaration
protected virtual void OnChanged(ListPropertyChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| ListPropertyChangedEventArgs | e | A ListPropertyChangedEventArgs that contains the event data. |
OnChanging(ListPropertyChangedEventArgs)
Raises the Changing event.
Declaration
protected virtual void OnChanging(ListPropertyChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| ListPropertyChangedEventArgs | e | A ListPropertyChangedEventArgs that contains the event data. |
Remove(FieldDescriptor)
Removes the specified descriptor element from the collection.
Declaration
public void Remove(FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor | value | The element to remove from the collection. If the value is NULL or the element is not contained in the collection, the method will do nothing. |
Remarks
The method ensures that the collection is in sync with the underlying table if changes have been made to the table or the TableDescriptor.
Remove(String)
Removes the specified descriptor element with the specified name from the collection.
Declaration
public void Remove(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the element to remove from the collection. If no element with that name is found in the collection, the method will do nothing. |
Remarks
The method ensures that the collection is in sync with the underlying table if changes have been made to the table or the TableDescriptor.
RemoveAt(Int32)
Removes the element at the specified index of the collection.
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the element to remove. |
Reset()
Resets the collection to its default state. If the collection is bound to a TableDescriptor, the collection will auto populate itself the next time an item inside the collection is accessed.
Declaration
public void Reset()
ShowAddRangeChangedWarning(String)
Internal only. ShowADdRangeChangedWarning display and warning message when the add range changed.
Declaration
public static void ShowAddRangeChangedWarning(string colName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | colName | The column name. |
SuggestName(FieldDescriptor)
Called to get a new default name when a new field descriptor is created (e.g. when pressing "Add" in a collection editor).
Declaration
protected virtual void SuggestName(FieldDescriptor value)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldDescriptor | value | The field descriptor to be named. |
ToString()
Returns string representation of this object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents the current System.Object. |
Overrides
Events
Changed
Occurs after a property in a nested element or the collection is changed.
Declaration
public event ListPropertyChangedEventHandler Changed
Event Type
| Type |
|---|
| ListPropertyChangedEventHandler |
Changing
Occurs before a property in a nested element or the collection is changed.
Declaration
public event ListPropertyChangedEventHandler Changing
Event Type
| Type |
|---|
| ListPropertyChangedEventHandler |
Explicit Interface Implementations
IInsideCollectionEditorProperty.InitializeFrom(Object)
Initialize the Field descriptor from the given object.
Declaration
void IInsideCollectionEditorProperty.InitializeFrom(object other)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | other |
ICollection.CopyTo(Array, Int32)
Copies the elements of the System.Collections.ICollection to an System.Array,starting at a particular System.Array index.
Declaration
void ICollection.CopyTo(Array array, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Array | array | The one-dimensional System.Array that is the destination of the elements copied from System.Collections.ICollection. The System.Array must have zero-based indexing. |
| System.Int32 | index | The zero-based index in array at which copying begins. |
ICollection.SyncRoot
Gets an object that can be used to synchronize access to the System.Collections.ICollection.
Declaration
object ICollection.SyncRoot { get; }
Returns
| Type |
|---|
| System.Object |
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator | Returns an enumerator that iterates through a collection. |
IList.Add(Object)
Adds an item to the System.Collections.IList.
Declaration
int IList.Add(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The object to add to the System.Collections.IList. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the collection, |
IList.Contains(Object)
Determines whether the System.Collections.IList contains a specific value.
Declaration
bool IList.Contains(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The object to locate in the System.Collections.IList. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the System.Object is found in the System.Collections.IList; otherwise, false. |
IList.get_Item(Int32)
Declaration
object IList.get_Item(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index |
Returns
| Type |
|---|
| System.Object |
IList.IndexOf(Object)
Determines the index of a specific item in the System.Collections.IList.
Declaration
int IList.IndexOf(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | he object to locate in the System.Collections.IList. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The index of value if found in the list; otherwise, -1. |
IList.Insert(Int32, Object)
Inserts an item to the System.Collections.IList at the specified index.
Declaration
void IList.Insert(int index, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index at which value should be inserted. |
| System.Object | value | The object to insert into the System.Collections.IList. |
IList.Item[Int32]
Gets or sets the element at the specified index.
Declaration
object IList.this[] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The zero-based index of the element to get or set. |
Returns
| Type | Description |
|---|---|
| System.Object | The element at the specified index. |
IList.Remove(Object)
Removes the first occurrence of a specific object from the System.Collections.IList.
Declaration
void IList.Remove(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The object to remove from the System.Collections.IList. |
IList.set_Item(Int32, Object)
Declaration
void IList.set_Item(int index, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | |
| System.Object | value |
ICloneable.Clone()
Crates the copy of the collection and its elements.
Declaration
object ICloneable.Clone()
Returns
| Type | Description |
|---|---|
| System.Object | A new object that is a copy of this instance. |