WPF Devexpress ComboBox编辑项目
我在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加
到 ComboBoxEdit 的 xaml 中。这是控件的一个已知问题,此处提到。我使用DX控件,我个人认为他们的Silverlight和WPF控件远远落后于市场上的其他控件(他们的Silverlight控件仍然是测试版,可以说当ComboBoxEdit包含这样的错误时那么WPF控件也应该被视为测试版)。你可能想坚持使用 MS 控件,直到 DX 修复他们的问题。
Add the
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.
如果您需要更复杂的行为,可以使用 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