简体   繁体   中英

Adding item to combobox in Delphi XE4 and Devexpress VCL 13.1

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?

您应该在数据集中添加'View all', 0行,并在初始化中将组合框的EditValue设置为0。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM