【问题标题】:Binding the enum values on to checked combobox edit in dev express将枚举值绑定到 dev express 中的选中组合框编辑
【发布时间】:2015-07-15 12:42:03
【问题描述】:

如何在 dev express 中为选中的组合框编辑控件提供枚举值?

public enum AccessRoles
{
    User,
    Administrator
}

foreach (var item in Enum.GetValues(typeof(AccessRoles)))
{
    checkedComboBoxEdit1.Properties.Items.AddRange(Enum.GetValues(typeof(item)));
}

如何将枚举值绑定到 checkedcomboBoxedit?

【问题讨论】:

  • 那么我们需要更多细节。这。请显示一些代码
  • checkedComboBoxEdit1.Properties.Items.AddRange(Enum.GetValues(typeof(AccessRoles)));
  • public enum AccessRoles { User, Administrator } foreach (var item in Enum.GetValues(typeof(AccessRoles))) { checkedComboBoxEdit1.Properties.Items.AddRange(Enum.GetValues(typeof(item))) ;我如何在上面的代码中将枚举的值绑定到选中的组合框编辑? @gunr2171

标签: c# devexpress


【解决方案1】:

试试这样的。将您的 comboboxedit 绑定到您的枚举列表(或其他)。

然后在你的comboboxedit

<dxe:ComboBoxEdit //stuff here>
     <dxmvvm:Interaction.Behaviors>
            <dxmvvm:EnumItemsSourceBehavior EnumType="{x:Type local:AccessRoles}" SortMode="DisplayName"/>
        </dxmvvm:Interaction.Behaviors>
        <dxe:ComboBoxEdit.ItemTemplate>
</dxe:ComboBoxEdit>

让我知道这是否有效,我以前从未亲自尝试过。它是 14.2 版的新版本,所以如果您有旧版本,请告诉我

【讨论】:

    【解决方案2】:

    这段代码用于将这些 Enum 值绑定到 CheckedComboEdit。

    checkedComboBoxEdit1.Properties.DataSource = Enum.GetValues(typeof(AccessRoles));

    【讨论】:

      猜你喜欢
      • 2012-08-19
      • 2011-08-04
      • 2018-11-12
      • 2020-02-07
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多