Back to Devexpress

RepositoryItemCollection Class

windowsforms-devexpress-dot-xtraeditors-dot-repository-4a62186f.md

latest6.7 KB
Original Source

RepositoryItemCollection Class

Represents a collection of repository items.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[ListBindable(false)]
public class RepositoryItemCollection :
    CollectionBase
vb
<ListBindable(False)>
Public Class RepositoryItemCollection
    Inherits CollectionBase

The following members return RepositoryItemCollection objects:

Remarks

The RepositoryItemCollection class maintains a list of items represented by RepositoryItem descendant objects (such as RepositoryItemButtonEdit, RepositoryItemCalcEdit and etc). Each repository item stores settings that can be used to create a fully functional editor

Methods introduced by this class can be used to perform common collection operations such as adding new or deleting existing repository items. Individual repository items can be accessed via the collection’s RepositoryItemCollection.Item property using indexer notation.

RepositoryItemCollection object can be accessed using a container control’s EditorContainer.RepositoryItems or container component’s ComponentEditorContainer.RepositoryItems property. Such collections represent the container controls’/components’ internal repositories. External repository components (PersistentRepository) also maintain collections of repository items available via their PersistentRepository.Items property.

Example

The following example uses a PersistentRepository to reuse a single repository item in a Data Grid and a Tree List.

csharp
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

public partial class Form1 : XtraForm {
    public Form1() {
        InitializeComponent();
        // Create a persistent repository
        PersistentRepository rep = new PersistentRepository();

        //Add a repository item to the persistent repository
        RepositoryItemSpinEdit spin = new RepositoryItemSpinEdit();
        rep.Items.Add(spin);

        //Link the persistent repository to controls
        gridControl1.ExternalRepository = rep;
        treeList1.ExternalRepository = rep;

        // Assign the repository item to columns
        gridView1.Columns["Id"].ColumnEdit = spin;
        treeList1.Columns["Id"].ColumnEdit = spin;
    }
}
vb
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Repository

Public Partial Class Form1
    Inherits XtraForm

    Public Sub New()
        InitializeComponent()
        ' Create a persistent repository
        Dim rep As New PersistentRepository()

        ' Add a repository item to the persistent repository
        Dim spin As New RepositoryItemSpinEdit()
        rep.Items.Add(spin)

        ' Link the persistent repository to controls
        gridControl1.ExternalRepository = rep
        treeList1.ExternalRepository = rep

        ' Assign the repository item to columns
        gridView1.Columns("Id").ColumnEdit = spin
        treeList1.Columns("Id").ColumnEdit = spin
    End Sub
End Class

Example

The following code shows how to assign a DateEdit in-place editor to a TreeList column in a TreeList control. This example creates the required repository item (RepositoryItemDateEdit), adds it to the control’s internal repository and then binds the repository item to a column.

csharp
RepositoryItemDateEdit riDateEdit = new RepositoryItemDateEdit();
// Customize the item...
// Add the item to the control's internal repository.
treeList1.RepositoryItems.Add(riDateEdit);
// Bind the item to the control's column.
treeList1.Columns["Start Date"].ColumnEdit = riDateEdit;
vb
Dim riDateEdit As RepositoryItemDateEdit = New RepositoryItemDateEdit()
' Customize the item...
' Add the item to the control's internal repository.
TreeList1.RepositoryItems.Add(riDateEdit)
' Bind the item to the control's column.
TreeList1.Columns("Start Date").ColumnEdit = riDateEdit

Inheritance

Object CollectionBase RepositoryItemCollection

See Also

RepositoryItemCollection Members

DevExpress.XtraEditors.Repository Namespace