WPF Devexpress ComboBox编辑项目

发布于 2024-08-12 12:17:08 字数 873 浏览 5 评论 0原文

我在我的 WPF 应用程序中使用 devexpress ComboBoxEdit 组件。我为它分配值,如下所示:

private void Users1_Load()
{
    DataTable dtCat = SqlHelper.GetTable("base_UserCategory_Select", new string[] { });
    DataRow dr = dtCat.NewRow();
    dr["UserCategoryID"] = 0;
    dr["CategoryName"] = "< All >";
    dr["IsSystem"] = "False";
    dtCat.Rows.InsertAt(dr, 0);
    comboBoxEdit1.ItemsSource = dtCat.DefaultView;
    comboBoxEdit1.SelectedIndex = 1;
}

我的 xaml:

<dxe:ComboBoxEdit Height="20" Margin="14,64,0,0" Name="comboBoxEdit1" DisplayMember = "CategoryName" ValueMember = "UserCategoryID" VerticalAlignment="Top" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" HorizontalAlignment="Left" Width="254" />

但问题是,在这个组合框中我看到我的 id(值成员),只有当我展开它时,我才会看到 DisplayMember 值。有什么问题,如何才能始终看到文本值,而不是我的 id 的..?

i use devexpress comboBoxEdit component in my WPF app. I assign values for it like this:

private void Users1_Load()
{
    DataTable dtCat = SqlHelper.GetTable("base_UserCategory_Select", new string[] { });
    DataRow dr = dtCat.NewRow();
    dr["UserCategoryID"] = 0;
    dr["CategoryName"] = "< All >";
    dr["IsSystem"] = "False";
    dtCat.Rows.InsertAt(dr, 0);
    comboBoxEdit1.ItemsSource = dtCat.DefaultView;
    comboBoxEdit1.SelectedIndex = 1;
}

My xaml:

<dxe:ComboBoxEdit Height="20" Margin="14,64,0,0" Name="comboBoxEdit1" DisplayMember = "CategoryName" ValueMember = "UserCategoryID" VerticalAlignment="Top" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" HorizontalAlignment="Left" Width="254" />

But the problem is, that in this combobox i see my id's (Value Members), only when i expand it, then i see DisplayMember values. Whats the problem, how to do to allways see text values, not my id's..?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过期以后 2024-08-19 12:17:08

添加

IsTextEditable="False"

到 ComboBoxEdit 的 xaml 中。这是控件的一个已知问题,此处提到。我使用DX控件,我个人认为他们的Silverlight和WPF控件远远落后于市场上的其他控件(他们的Silverlight控件仍然是测试版,可以说当ComboBoxEdit包含这样的错误时那么WPF控件也应该被视为测试版)。你可能想坚持使用 MS 控件,直到 DX 修复他们的问题。

Add the

IsTextEditable="False"

to your xaml for the ComboBoxEdit. This is a known issue with the control, mentioned here. I use DX controls, and personally i think their Silverlight and WPF controls are a long way behind the rest of the market (their Silverlight controls are still beta, arguably when the ComboBoxEdit contains a bug like this then the WPF controls should be considered beta too). You might want to stick to the MS controls until DX fix their crap.

荆棘i 2024-08-19 12:17:08

如果您需要更复杂的行为,可以使用 DevExpress LookUpEdit 组件 http://documentation.devexpress.com /#WindowsForms/clsDevExpressXtraEditorsLookUpEdittopic

If you need a more complex behaviour, you can use the DevExpress LookUpEdit component http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsLookUpEdittopic

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文