Consider the following example, in which the Country field is represented by a short character code.
To display the character codes as proper names, use the column's ValueItemCollection object to specify automatic data translations. At design time, this is done with .NET's ValueItemCollection editor.
Altering the ValueItemCollection object through the collection editor enables you to specify data translations on a per-column basis in a simple window. To construct a list of data translations for an individual column, complete the following steps:
When the program is run, Country field values that match any items in the Value column appear as the corresponding DisplayValue entry. For example, CAN becomes Canada, UK becomes UnitedKingdom, and so on.
Note that the underlying database is not affected; only the presentation of the data value is different. The same effect can be achieved in code as follows:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim v as C1.Win.C1TrueDBGrid.ValueItemCollection v = Me.C1TrueDBGrid1.Columns("Country").ValueItems.Values v.Add(new C1.Win.C1TrueDBGrid.ValueItem("CAN","Canada")) v.Add(new C1.Win.C1TrueDBGrid.ValueItem("UK","United Kingdom")) v.Add(new C1.Win.C1TrueDBGrid.ValueItem("USA","United States")) v.Add(new C1.Win.C1TrueDBGrid.ValueItem("JPN","Japan")) v.Add(new C1.Win.C1TrueDBGrid.ValueItem("AUS","Australia")) Me.C1TrueDBGrid1.Columns("Country").ValueItems.Translate = True |
To write code in C#
C# |
Copy Code
|
---|---|
C1.Win.C1TrueDBGrid.ValueItemCollection v = this.c1TrueDBGrid1.Columns["Country"].ValueItems.Values; v.Add(new C1.Win.C1TrueDBGrid.ValueItem("CAN","Canada")); v.Add(new C1.Win.C1TrueDBGrid.ValueItem("UK","United Kingdom")); v.Add(new C1.Win.C1TrueDBGrid.ValueItem("USA","United States")); v.Add(new C1.Win.C1TrueDBGrid.ValueItem("JPN","Japan")); v.Add(new C1.Win.C1TrueDBGrid.ValueItem("AUS","Australia")); this.c1TrueDBGrid1.Columns["Country"].ValueItems.Translate = true; |