List items

Top  Previous  Next

DFM-Translator > Special assignments > Lists > List items

Examples of components with list properties are TListBox, TComboBox, etc. The elements that are assigned to a combo box, for example, are put in parenthesis in a DFM file, like:

 

  object ComboBox1: TComboBox

   ...

    Items.Strings = (

      'first'

      'second'

    )

  end

 

By default, this is translated by Delphi2C# in the following way:

 

  ComboBox1 = new TComboBox(this);

  ...

  ComboBox1->Items->Add(L"first");

  ComboBox1->Items->Add(L"second");

 

 

Here too, Delphi2C# can be configured to output special assignment functions. With TComboBox as type and Items as name part results:

 

  ComboBox1 = new TComboBox(this);

  ...

  AssignTComboBoxItems(ComboBox1, L"first", 0);

  AssignTComboBoxItems(ComboBox1, L"second", 1);

 

Here the assignment procedure a third parameter is passed, which is the number of the list value.

 

The type of the Items property is TStrings and TStrings has the property:

 

property Strings[Index: Integer]: string read Get write Put; default;

 

 

So also an assignment procedure for all TStrings can be defined:

 

  ComboBox1 = new TComboBox(this);

  ...

  AssignTStringsStrings(ComboBox1->Items, L"first", 0);

  AssignTStringsStrings(ComboBox1->Items, L"second", 1);

 

 

However, this procedure would be applied to all TStrings, not just those from TComboBox, and it would not be applied if AssignTComboBoxItems also existed.

 

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content