Difference between revisions of "TGComboBox"

From Gestinux Wiki
Jump to navigation Jump to search
(Created page with "This control is a TCombobox, with a TLabel to display the caption, and a Translate procedure, as in all other data entry components You w...")
 
 
Line 1: Line 1:
 
This control is a TCombobox, with a TLabel to display the caption, and a Translate procedure, as in all other [[Gestinux_util#Visual_components|data entry components]]  
 
This control is a TCombobox, with a TLabel to display the caption, and a Translate procedure, as in all other [[Gestinux_util#Visual_components|data entry components]]  
  
You will have to override de ''Translate'' procedure of the TGForm containing this TGComboBox, to fill items with translations in the current language. See examples.
+
The items must not be set at designtime in lfm (the property should be removed in the future) but at runtime. The item texts must be set in the ''Translate'' procedure of the TGForm containing this TGComboBox, to fill items with translations in the current language. AddItem and InsertItem should be used associating a code independant of the language, to indicate the exact meaning of the item.  
  
If the items are sorted, the item index will depend on the language. You must not use the ItemIndex only, but you should store in the Objects property some constant independant of the language, to indicate the exact meaning of the item.
 
  
Note that the button is on the right size of the box, unlike [[TGEditButton]] component. If possible, we will move it between the label and the box.
+
procedure TFormJournal.Translate;
 +
var
 +
  I: word;
 +
  P: integer;
 +
begin
 +
  inherited Translate;
 +
  // fill EditJournalClass PickList
 +
  P := EditJournalClass.ItemIndex;
 +
  EditJournalClass.Clear;
 +
  for I := Low(JournalClass) to High(JournalClass) do
 +
    EditJournalClass.AddItem(LibClassJournal(JournalClass[I]),
 +
      IntToStr(JournalClass[I]));
 +
  EditJournalClass.ItemIndex := P;
 +
end; 
 +
 
 +
This is necessary to allow dynamic translation.
 +
 
 +
The button is on the right size of the box, unlike [[TGEditButton]] component. If possible, we will move it between the label and the box.
  
 
[[Gestinux_util#Visual_components|Other data entry components]]
 
[[Gestinux_util#Visual_components|Other data entry components]]

Latest revision as of 11:15, 14 March 2016

This control is a TCombobox, with a TLabel to display the caption, and a Translate procedure, as in all other data entry components

The items must not be set at designtime in lfm (the property should be removed in the future) but at runtime. The item texts must be set in the Translate procedure of the TGForm containing this TGComboBox, to fill items with translations in the current language. AddItem and InsertItem should be used associating a code independant of the language, to indicate the exact meaning of the item.


procedure TFormJournal.Translate;
var
 I: word;
 P: integer;
begin
 inherited Translate;
 // fill EditJournalClass PickList
 P := EditJournalClass.ItemIndex;
 EditJournalClass.Clear;
 for I := Low(JournalClass) to High(JournalClass) do
   EditJournalClass.AddItem(LibClassJournal(JournalClass[I]),
     IntToStr(JournalClass[I]));
 EditJournalClass.ItemIndex := P;
end;  

This is necessary to allow dynamic translation.

The button is on the right size of the box, unlike TGEditButton component. If possible, we will move it between the label and the box.

Other data entry components