RepositoryItemTokenEdit.EditValueType Property
Gets or sets the type of this TokenEdit‘s edit value.
Namespace: DevExpress.XtraEditors.Repository
Assembly: DevExpress.XtraEditors.v24.2.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
[DefaultValue(TokenEditValueType.String)]
[DXCategory("Data")]
public TokenEditValueType EditValueType { get; set; }
#Property Value
Type | Default | Description |
---|---|---|
Token |
String | A Token |
Available values:
Name | Description |
---|---|
String | The Edit |
List | The Edit |
Enum | The Edit |
#Remarks
Depending on the EditValueType property value, the editor’s EditValue property returns a value of the following type:
- String (the default value) — a System.String value that contains selected tokens. To separate tokens, the editor uses the EditValueSeparatorChar property value and a space character.
List — a ComponentModel.BindingList object that contains selected tokens.
Note
You cannot assign a Token
Edit that contains a BindingList to a Grid<T> Column since the GridControl creates detail views for data fields that contain collections. Use this edit value type for standalone editors only.Enum — System.Enum values, which are selected tokens.
Important
The enumeration must apply the Flags attribute. See the following help topic for more information: Non-Exclusive Members and the Flags Attribute.
Note
An exception is thrown if you set the Add
Enum method’s add(Type, Boolean) Enumerator parameter to true while theInteger Values Edit
option is set to Enum. Set theValue Type Edit
option to String or List, or set the addValue Type Enumerator parameter to false.Integer Values
#Example
The following code populates a TokenEdit with enumeration values.
//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
}
#Related GitHub Examples
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.