ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Specifying Text-to-Picture Translations

The same techniques used to specify text-to-text translations can also be used for text-to-picture translations. Within the ValueItem Collection Editor, instead of typing a string into the DisplayValue column, 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, it may be necessary to increase the value of the RowHeight property. If that is done, change the VerticalAlignment member of the grid's Style property to Center to ensure that the bitmaps (as well as textual data in other columns) are centered vertically within grid 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:

·      Visual Basic

Dim item As C1.Win.C1TrueDBGrid.ValueItem = New C1.Win.C1TrueDBGrid.ValueItem()

With Me.C1TrueDBGrid1.Columns("Country").ValueItems.Values

    Item.Value = "CAN"

    Item.DisplayValue = System.Drawing.Image.FromFile("canada.bmp")

    .Add(Item)

 

    Item = New C1.Win.C1TrueDBGrid.ValueItem()

    Item.Value = "UK"

    Item.DisplayValue = System.Drawing.Image.FromFile("uk.bmp")

    .Add(Item)

 

    Item = New C1.Win.C1TrueDBGrid.ValueItem()

    Item.Value = "USA"

    Item.DisplayValue = System.Drawing.Image.FromFile("usa.bmp")

    .Add(Item)

 

    Item = New C1.Win.C1TrueDBGrid.ValueItem()

    Item.Value = "JPN"

    Item.DisplayValue = System.Drawing.Image.FromFile("japan.bmp")

    .Add(Item)

 

    Item = New C1.Win.C1TrueDBGrid.ValueItem()

    Item.Value = "AUS"

    Item.DisplayValue = System.Drawing.Image.FromFile("australia.bmp")

    .Add(Item)

 

    Me.C1TrueDBGrid1.Columns("Country").ValueItems.Translate = True

End With

·      C#

C1.Win.C1TrueDBGrid.ValueItemCollection v = this.c1TrueDBGrid.Columns["Country"].ValueItems.Values;

C1.Win.C1TrueDBGrid.ValueItem Item = new C1.Win.C1TrueDBGrid.ValueItem();

 

    Item.value = "CAN";

    Item.DisplayValue = System.Drawing.Image.FromFile["canada.bmp"];

    v.Add[Item];

 

    Item = new C1.Win.C1TrueDBGrid.ValueItem();

    Item.value = "UK";

    Item.DisplayValue = System.Drawing.Image.FromFile["uk.bmp"];

    v.Add[Item];

 

    Item = new C1.Win.C1TrueDBGrid.ValueItem();

    Item.value = "USA";

    Item.DisplayValue = System.Drawing.Image.FromFile["usa.bmp"];

    v.Add[Item];

 

    Item = new C1.Win.C1TrueDBGrid.ValueItem();

    Item.value = "JPN";

    Item.DisplayValue = System.Drawing.Image.FromFile["japan.bmp"];

    v.Add[Item];

 

    Item = new C1.Win.C1TrueDBGrid.ValueItem();

    Item.value = "AUS";

    Item.DisplayValue = System.Drawing.Image.FromFile["australia.bmp"];

    v.Add[Item];

 

    this.c1TrueDBGrid1.Columns["Country"].ValueItems.Translate = true;

·      Delphi

var item1: C1TrueDBGrid.ValueItem;

 

with Self.C1TrueDBGrid1.Columns['Country'] do

begin

  item1 := C1.Win.C1TrueDBGrid.ValueItem.Create;

  item1.Value := 'CAN';

  item1.DisplayValue := System.Drawing.Image.FromFile('canada.bmp');

  Add(item1);

 

  item1 := C1.Win.C1TrueDBGrid.ValueItem.Create;

  item1.Value := 'UK';

  item1.DisplayValue := System.Drawing.Image.FromFile('uk.bmp');

  Add(item1);

 

  item1 := C1.Win.C1TrueDBGrid.ValueItem.Create;

  item1.Value := 'USA';

  item1.DisplayValue := System.Drawing.Image.FromFile('us.bmp');

  Add(item1);

 

  item1 := C1.Win.C1TrueDBGrid.ValueItem.Create;

  item1.Value := 'JPN';

  item1.DisplayValue := System.Drawing.Image.FromFile('japan.bmp');

  Add(item1);

 

  item1 := C1.Win.C1TrueDBGrid.ValueItem.Create;

  item1.Value := 'AUS';

  item1.DisplayValue := System.Drawing.Image.FromFile('australia.bmp');

  Add(item1);

 

  Self.C1TrueDBGrid1.Columns['Country'].ValueItems.Translate := True;

end;


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.