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

    The same techniques used to specify text-to-text translations can also be used for text-to-picture translations. Within the ValueItems Collection Editor, instead of typing a string into the DisplayValue column, you can use the ellipsis button to select a bitmap to be used for data translations. To delete your bitmap selection, simply delete the text in the DisplayValue property box and either select another bitmap or type in text.

    Note that the Translate property for the ValueItems object must be set to True. Depending upon the height of the bitmaps, you may need to increase the value of the ItemHeight property in the Properties window. If you do so, you may also want to change the VerticalAlignment member of the list's Style property to Center. This ensures that the bitmaps (as well as textual data in other columns) are centered vertically within list cells instead of being anchored at the top.

    When the program is run, Country field values that match an item in the Value column appear as the corresponding DisplayValue picture.

    As with textual translations, 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 = System.Drawing.Image.FromFile("canada.bmp")  
        .Add(Item)
    
        Item = new C1.Win.C1List.ValueItem()
        Item.Value = "UK"
        Item.DisplayValue = System.Drawing.Image.FromFile("uk.bmp")
        .Add(Item)
    
        Item = new C1.Win.C1List.ValueItem()
        Item.Value = "USA"
        Item.DisplayValue = System.Drawing.Image.FromFile("usa.bmp")
        .Add(Item)
    
        Item = new C1.Win.C1List.ValueItem()
        Item.Value = "JPN"
        Item.DisplayValue = System.Drawing.Image.FromFile("japan.bmp")
        .Add(Item)
    
        Item = new C1.Win.C1List.ValueItem()
        Item.Value = "AUS"
        Item.DisplayValue = System.Drawing.Image.FromFile("australia.bmp")     
        .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 = System.Drawing.Image.FromFile("canada.bmp");
    values.Add(Item); 
    Item = new C1.Win.C1List.ValueItem();
    Item.Value = "UK";
    Item.DisplayValue = System.Drawing.Image.FromFile("uk.bmp");      
    values.Add(Item);
       
    Item = new C1.Win.C1List.ValueItem();
    Item.Value = "USA";    
    Item.DisplayValue = System.Drawing.Image.FromFile("usa.bmp");  
    values.Add(Item);
          
    Item = new C1.Win.C1List.ValueItem();
    Item.Value = "JPN";    
    Item.DisplayValue = System.Drawing.Image.FromFile("japan.bmp");
    values.Add(Item); 
    Item = new C1.Win.C1List.ValueItem();
    Item.Value = "AUS";
    Item.DisplayValue = System.Drawing.Image.FromFile("australia.bmp");    
    values.Add(Item);
    
    this.c1List1.Columns["Country"].ValueItems.Translate = true;