How to Set a Default Selection for a TColumnComboBox Using the LookupColumn?

With run-time 2-Column Items as follows:
Caption1 w1
Unicode2 w2
SomeTxT3 w4
....
LookupColumn := 1; // Hope to represent key fields
EditColumn := 0; // When static, the first column is Displayed
SortColumn := 2; // Sort by key fields

How to put "w4" then "SomeTxT3" Item is Default?
sometime first column is Unicode, which varies on User-Site.
Moreover, some user prefer sorting by first Column.
Thank you.

You mention you use 2 columns. Note that column indexing starts at 0, thus sorting on the first column means you need to set SortColumn = 0. In a 2 column situation, the last column has index 1, so it does not make sense to set this to two.
I'm not sure what exactly you mean with:
"How to put "w4" then "SomeTxT3" Item is Default?"
The item that is selected is typically set with the ItemIndex property, also a property that is zero based.

Sorting topics, try like 1-Base. maybe i'm wrong.
ColumnCombobox_5.mp4
0-is no change

Default topics,
now can this to Default:(Unicode is change)
ColumnComboBox5.SelectItem('#-1|Unicode2|w2');
Is there a way to use the Key field to specify. example:
ColumnComboBox5.KeyValue := 'w4';
(Maybe I know too little)
ColumnCombobox5.7z

Thank for your reply.

  1. I overlooked that the SortColumn is indeed 1 based. Internally the first column can be used to show an image and that it the reason it is 1 based
  2. SelectItem() cannot be used this way. SelectItem searches on the internal string for an combobox item but here a combobox item consists of a string per column. To select an item, use

ColumnComboBox.ItemIndex := ColumnComboBox.ComboItems.IndexInColumnOf(ColumnIndex: integer; ColumnValue: string)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.