Back to Devexpress

RepositoryItemTokenEdit.EditValueType Property

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemtokenedit.md

latest8.5 KB
Original Source

RepositoryItemTokenEdit.EditValueType Property

Gets or sets the type of this TokenEdit‘s edit value.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(TokenEditValueType.String)]
[DXCategory("Data")]
public TokenEditValueType EditValueType { get; set; }
vb
<DXCategory("Data")>
<DefaultValue(TokenEditValueType.String)>
Public Property EditValueType As TokenEditValueType

Property Value

TypeDefaultDescription
TokenEditValueTypeString

A TokenEditValueType enumeration value that specifies the type of this TokenEdit‘s edit value.

|

Available values:

NameDescription
String

The EditValue property returns a System.String value that contains the selected tokens separated with a comma.

| | List |

The EditValue property returns a ComponentModel.BindingList object that contains selected tokens.

| | Enum |

The EditValue property returns System.Enum values, which are selected tokens.

|

Remarks

Depending on the EditValueType property value, the editor’s EditValue property returns a value of the following type:

Example

The following code populates a TokenEdit with enumeration values.

csharp
//Create a RepositoryItemTokenEdit that works with an enumeration.
    RepositoryItemTokenEdit tokenRep = new DevExpress.XtraEditors.Repository.RepositoryItemTokenEdit() { EditValueType = DevExpress.XtraEditors.TokenEditValueType.Enum };
    //Populate the editor with the enumeration values.
    tokenRep.Tokens.AddEnum(typeof(ProductCategory));
    //Add the editor to the GridControl's repository item collection.
    gridControl1.RepositoryItems.Add(tokenRep);
    //Assign the RepositoryItemTokenEdit object to the Category column.
    gridView1.Columns["Category"].ColumnEdit = tokenRep;
    gridView1.SetRowCellValue(0, "Category", ProductCategory.Meat | ProductCategory.DairyProducts);

    //The Product class instances are displayed within the GridControl.
    public class Product {
        public double UnitPrice { get; set; }
        [EnumDataType(typeof(ProductCategory))]
        public ProductCategory Category { get; set; }
        public int Quantity { get; set; }
        public string Text { get; set; }
        [DataType(DataType.MultilineText)]
        public string MultilineText { get; set; }
        [DataType(DataType.Currency), Range(200, 5000)]
        public int Currency { get; set; }
        [DataType(DataType.Date)]
        public DateTime Date { get; set; }
        [DataType(DataType.Time)]
        public DateTime Time { get; set; }
    }

    //A custom enumeration. The Flags attribute is mandatory.
    [Flags]
    public enum ProductCategory {
        //Use integers that permit bitwise combinations.
        Fruit = 1,
        Vegetables = 2,
        Meat = 4,
        Condiments = 8,
        Confections = 16,
        DairyProducts = 32,
        GrainsCereals = 64,
        Seafood = 128,
        //If both 'Fruit' and 'Meat' tokens are added, the EditValue property returns 'All'.
        All = Fruit | Meat
    }
vb
'Create a RepositoryItemTokenEdit that works with an enumeration.
    Private tokenRep As RepositoryItemTokenEdit = New DevExpress.XtraEditors.Repository.RepositoryItemTokenEdit() With {.EditValueType = DevExpress.XtraEditors.TokenEditValueType.Enum}
    'Populate the editor with the enumeration values.
    tokenRep.Tokens.AddEnum(GetType(ProductCategory))
    'Add the editor to the GridControl's repository item collection.
    gridControl1.RepositoryItems.Add(tokenRep)
    'Assign the RepositoryItemTokenEdit object to the Category column.
    gridView1.Columns("Category").ColumnEdit = tokenRep

    'The Product class instances are displayed within the GridControl.
    public class Product
        public Double UnitPrice {get;set;}
        <EnumDataType(GetType(ProductCategory))>
        public ProductCategory Category {get;set;}
        public Integer Quantity {get;set;}
        public String Text {get;set;}
        <DataType(DataType.MultilineText)>
        public String MultilineText {get;set;}
        <DataType(DataType.Currency), Range(200, 5000)>
        public Integer Currency {get;set;}
        <DataType(DataType.Date)>
        public DateTime [Date] {get;set;}
        <DataType(DataType.Time)>
        public DateTime Time {get;set;}

    'A custom enumeration. The Flags attribute is mandatory.
    <Flags>
    public enum ProductCategory
        'Use integers that permit bitwise combinations.
        Fruit = 1,
        Vegetables = 2,
        Meat = 4,
        Condiments = 8,
        Confections = 16,
        DairyProducts = 32,
        GrainsCereals = 64,
        Seafood = 128,
        'If both 'Fruit' and 'Meat' tokens are added, the EditValue property returns 'All'.
        All = Fruit Or Meat

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EditValueType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-tokenedit-in-unbound-column/CS/Form1.cs#L36

csharp
rep.Name = "rep";
rep.EditValueType = TokenEditValueType.List;
gridControl.RepositoryItems.Add(rep);

winforms-grid-tokenedit-in-unbound-column/VB/Form1.vb#L38

vb
rep.Name = "rep"
rep.EditValueType = TokenEditValueType.List
gridControl.RepositoryItems.Add(rep)

See Also

EditValueSeparatorChar

Token Edit Control

RepositoryItemTokenEdit Class

RepositoryItemTokenEdit Members

DevExpress.XtraEditors.Repository Namespace