Pergunta

I have following code:

var
cbMyCombo: TcxLookupComboBox;

I have a dataset which has following query:

SELECT ID, NAME from MYTABLE;

This query works fine.

Now I have done binding in cbMyCombo in DFM file as following:

object cbMyCombo: TcxLookupComboBox
  Properties.KeyFieldNames = 'ID'
  Properties.ListColumns = <
    item
      FieldName = 'NAME'
    end>
end

It works fine and combobox is binded. My problem is, nothing is selected by default. I want that initially combobox should contain "View All" option.

I am trying like this:

cbMyCombo.Text := 'View All'

But, this is not setting anything because "View All" is not the part of the list which I have binded to it. I want to manually add "View All" as FieldName and 0 as KeyFieldName and this should be selected by default. How can I do this?

Foi útil?

Solução

You should add the 'View all', 0 row to your dataset and set the EditValue of your combobox to 0 in your intialization.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top