ComponentOne List for WinForms
In This Topic
    Specifying Text-to-Text Translations
    In This Topic

    Consider the following example in which the Country field is represented by a short character code:

    To display the character codes as proper names, you can use the column's ValueItemCollection object to specify automatic data translations. At design time, this is done with .NET's ValueItem Collection 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, do the following:

    1. 1 Open up the C1List Designer by clicking on the ellipsis button ( ) next to the Columns collection in the Properties window
    2. 2 Select the column whose contents you would like translated in the left pane. In the right pane expand the ValueItems Node. Click the ellipsis button next to the Values Node to bring up the ValueItem Collection Editor
    3. 3 Click the Add button in the left pane to add ValueItem objects. In the right pane specify a Value and DisplayValue for each ValueItem. When entering the Value text, disregard the ellipsis button. This is used for entering a bitmap as a DisplayValue
    4. 4 After the ValueItem objects are configured correctly, select OK and return to the C1List Designer. In the right pane under the ValueItems node, set the Translate property to True
    5. 5 Select OK or Apply to commit the changes

    When the program is run, Country field values that match an item in the Value column appear as the corresponding DisplayValue entry. For example, CAN becomes Canada, UK becomes United Kingdom, and so forth

    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 Item As C1.Win.C1List.ValueItem
          
    With Me.C1List1.Columns("Country").ValueItems.Values    
        Item = New C1.Win.C1List.ValueItem() 
        Item.Value = "CAN"   
        Item.DisplayValue = "Canada"    
        .Add(Item)
      
        Item = New C1.Win.C1List.ValueItem()   
        Item.Value = "UK"
        Item.DisplayValue = "United Kingdom"  
        .Add(Item)
      
        Item = New C1.Win.C1List.ValueItem()  
        Item.Value = "USA"
        Item.DisplayValue = "United States"  
        .Add(Item)
       
        Item = New C1.Win.C1List.ValueItem() 
        Item.Value = "JPN"  
        Item.DisplayValue = "Japan"
        .Add(Item)
    
        Item = New C1.Win.C1List.ValueItem()  
        Item.Value = "AUS"
        Item.DisplayValue = "Australia"
        .Add(Item)
    
        Me.C1List1.Columns("Country").ValueItems.Translate = True     
    End With
    

    To write code in C#

    C#
    Copy Code
    C1.Win.C1List.ValueItem Item;
         
    C1.Win.C1List.ValueItem Item = new C1.Win.C1List.ValueItem();      
    C1.Win.C1List.ValueItemCollection values = this.c1List1.Columns[0].ValueItems.Values;     
    Item.Value = "CAN";     
    Item.DisplayValue = "Canada";    
    values.Add(Item);
        
    Item = new C1.Win.C1List.ValueItem();      
    Item.Value = "UK";      
    Item.DisplayValue = "United Kingdom";
    values.Add(Item);
        
    Item = new C1.Win.C1List.ValueItem();    
    Item.Value = "USA"; 
    Item.DisplayValue = "United States";
    values.Add(Item);
        
    Item = new C1.Win.C1List.ValueItem();     
    Item.Value = "JPN";    
    Item.DisplayValue = "Japan";  
    values.Add(Item);
         
    Item = new C1.Win.C1List.ValueItem();      
    Item.Value = "AUS";    
    Item.DisplayValue = "Australia";
    values.Add(Item);
     
    this.c1List1.Columns["Country"].ValueItems.Translate = true;