RepositoryItemTokenEdit.EditValueType Property
Gets or sets the type of this TokenEdit‘s edit value.
Namespace: DevExpress.XtraEditors.Repository
Assembly: DevExpress.XtraEditors.v19.1.dll
Declaration
[DXCategory("Data")]
[DefaultValue(TokenEditValueType.String)]
[SmartTagProperty("Edit Value Type", "Behavior", SortOrder = 55)]
public TokenEditValueType EditValueType { get; set; }
Property Value
Type | Default | Description |
---|---|---|
DevExpress.XtraEditors.TokenEditValueType | **String** | A DevExpress.XtraEditors.TokenEditValueType enumerator value that specifies the type of this TokenEdit‘s edit value. |
Remarks
Depending on the EditValueType property value, Token Edit Control can work with edit values of three types.
- By default, the EditValueType property equals TokenEditValueType.String. This means the editor’s BaseEdit.EditValue property’s value is represented as a string that contains values of all currently selected tokens (RepositoryItemTokenEdit.SelectedItems), divided by a separator character (see the RepositoryItemTokenEdit.EditValueSeparatorChar property) and a space character.
- If the EditValueType property is set to TokenEditValueType.List, the edit value is a System.ComponentModel.BindingList structure that contains selected token values.
When the EditValueType property equals TokenEditValueType.Enum, the editor is able to work with tokens that are values of the specific enumeration. This feature is most useful when the control is used as an in-place editor for a GridColumn.
Important
The RepositoryItemTokenEdit with Enum edit value type requires an enumeration with the [Flags] attribute to work properly. See the Non-Exclusive Members and the Flags Attribute MSDN topic to learn more.
The following code illustrates how to populate a token edit with enumeration values.
//Creating a RepositoryItemTokenEdit that will work with enumeration RepositoryItemTokenEdit tokenRep = new DevExpress.XtraEditors.Repository.RepositoryItemTokenEdit() { EditValueType = DevExpress.XtraEditors.TokenEditValueType.Enum }; //Populating the editor with enumeration values tokenRep.Tokens.AddEnum(typeof(ProductCategory)); //Adding the editor into the GridControl's repository items collection gridControl1.RepositoryItems.Add(tokenRep); //Setting the RepositoryItemTokenEdit object as the in-place editor for the 'Category' column gridView1.Columns["Category"].ColumnEdit = tokenRep; //The Product class, instances of which 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; } } //Custom enumeration. The [Flags] attribute is mandatory [Flags] public enum ProductCategory { //Assign different degrees of number '2' as values for each new enumeration item Fruit = 1, Vegetables = 2, Meat = 4, Condiments = 8, Confections = 16, DairyProducts = 32, GrainsCereals = 64, Seafood = 128, //If the both 'Fruit' and 'Meat' tokens are added, the EditValue property will return 'All' All = Fruit | Meat }
The following figure illustrates a GridControl filled with sample data of the Product class.
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.