Back to Devexpress

EditorContainer.ExternalRepository Property

windowsforms-devexpress-dot-xtraeditors-dot-container-dot-editorcontainer-c854959e.md

latest4.6 KB
Original Source

EditorContainer.ExternalRepository Property

Gets or sets the external repository of in-place editors.

Namespace : DevExpress.XtraEditors.Container

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Data")]
public PersistentRepository ExternalRepository { get; set; }
vb
<DXCategory("Data")>
<DefaultValue(Nothing)>
Public Property ExternalRepository As PersistentRepository

Property Value

TypeDefaultDescription
PersistentRepositorynull

A PersistentRepository component holding a collection of in-place editors (repository items).

|

Remarks

Repository items are used to create in-place editors within container controls (GridControl, TreeList, etc.). To use a specific repository item within a container control, the item must be added to the control’s internal repository (see EditorContainer.RepositoryItems) or external repository. Repository items added to a control’s internal repository cannot be used in other controls. To share the same repository item between multiple controls residing on a single form, use an external repository encapsulated by the PersistentRepository component.

You can work with an external repository as follows:

  • Place a PersistentRepository component onto the form;
  • Add repository items to the created repository and customize their settings as required;
  • Assign the repository to the ExternalRepository property of target container controls/components.
  • Associate the control’s elements (columns, cells, etc) to the repository items stored within the specified external repository.

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

See Also

RepositoryItems

EditorContainer Class

EditorContainer Members

DevExpress.XtraEditors.Container Namespace