ComboBox不显示连续列 [英] ComboBox not displaying concatenated columns

查看:46
本文介绍了ComboBox不显示连续列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码加载组合框:



I'm using the following code to load a combobox:

string sql = @"SELECT FilmID, Vendor.VendorName || ' ' || Film.Model, Film.Active ";
           sql = sql + @"FROM Film JOIN Vendor ";
           sql = sql + @"USING (VendorID) ";
           sql = sql + @"WHERE Film.Active = 1 OR Film.Active = 'True' ";
           sql = sql + @"ORDER BY Vendor.VendorName, Film.Model";

           SQLiteCommand com = new SQLiteCommand(sql, conn);
           dataTable = new DataTable("Film");
           SQLiteDataAdapter ad = new SQLiteDataAdapter(sql, conn);
           ad.Fill(dataTable);
           dataTable.Rows.Add(99999, eesConstants.EESADDEDIT);
           this._dataSet.Tables.Add(dataTable);
           this.comboboxSessionAnalogFilm.ItemsSource = this._dataSet.Tables["Film"].DefaultView;
           this.comboboxSessionAnalogFilm.DisplayMemberPath = this._dataSet.Tables["Film"].Columns[1].ToString();



我已经验证Column [1]是Vendor.VendorName || ''|| Film.Model



如果我将DisplayMemberPath更改为Column [0](FilmID)或Column [2](Active),则组合框将使用该数据进行更新。 br />


我对没有连接列的表没有任何问题。



有没有解决这个问题吗?



谢谢。


I have verified that Column[1] is Vendor.VendorName || ' ' || Film.Model

If I change the DisplayMemberPath to Column[0] (FilmID), or Column[2] (Active) the combobox is updated with that data.

I'm not having any problem with tables that don't have concatenated columns.

Is there a way around this?

Thank you.

推荐答案

你没有发布XAML但是基于在查询上我会说问题是你没有为连接列定义别名。因此,它将有一些默认名称。



尝试以下查询

You didn't post the XAML but based on the query I'd say the problem is that you don't define an alias for the concatenated column. Because of this it will have some default name.

Try the following query
string sql = @"
SELECT FilmID, 
       Vendor.VendorName || ' ' || Film.Model AS CompleteName, 
       Film.Active 
FROM Film JOIN Vendor 
USING (VendorID) 
WHERE Film.Active = 1 
OR    Film.Active = 'True' 
ORDER BY Vendor.VendorName, Film.Model";



和XAML定义 DisplayMemberPath CompleteName


这篇关于ComboBox不显示连续列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆