문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top