我使用ComboBoxEdit(DevExpress)和CheckedComboBoxStyle设置进行过滤。我如何通过代码选择一些项目?
答案 0 :(得分:2)
根据文件:
http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsCheckedComboBoxEdittopic
要编辑一组布尔选项,请将相应的项添加到RepositoryItemCheckedComboBoxEdit.Items集合中。每个项目由CheckedListBoxItem对象表示,提供以下选项:
ListBoxItem.Value - represents the item's value. Typically, this property must specify a unique string. For check items, it's also possible to specify the display text via the CheckedListBoxItem.Description property.
CheckedListBoxItem.CheckState - represents the item's check state (checked or unchecked). The indeterminate state is not supported.
CheckedListBoxItem.Enabled - specifies whether the item's state can be changed by an end-user.
答案 1 :(得分:1)
请将必要的项目添加到ComboBoxEdit.SelectedItems集合
标记:
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
...
<dxe:ComboBoxEdit x:Name="cbEdit" IsTextEditable="False">
<dxe:ComboBoxEdit.StyleSettings>
<dxe:CheckedComboBoxStyleSettings />
</dxe:ComboBoxEdit.StyleSettings>
</dxe:ComboBoxEdit>
代码背后:
string[] platforms = new string[] { "Win98", "Win2000", "WinNT", "WinXP", "Vista", "Win7" };
cbEdit.ItemsSource = platforms;
cbEdit.SelectedItems.Add(platforms[4]);
cbEdit.SelectedItems.Add(platforms[5]);