【发布时间】:2017-04-10 21:39:20
【问题描述】:
我处理两个带有以下代码的组合框:
var Masters = new List<KeyValuePair<long, string>>();
using (var ctx = new GestioneCaricoEntities())
{
var comti = ctx.ViewMasters.OrderBy(m => m.Lastname).ToList();
foreach (var t in comti)
{
Masters.Add(new KeyValuePair<long, string>(t.Id, t.Lastname));
}
}
cmbComteCaricazione.ItemsSource = Masters;
和
<ComboBox x:Name="cmbComteCaricazione" Margin="0,5,0,0"
DisplayMemberPath="Value" SelectedValuePath="Key" Width="110" IsEditable="True" />
我保存在数据库中:
ts.IdComandanteCaricazione = (long?)cmbComteCaricazione.SelectedValue;
问题:一切都以正确的方式进行,db 中的表字段具有 idComandanteCaricazione 但是当我再次加载窗口时,我希望看到 cmbComteCaricazione.text 中的值。 我该怎么做?
【问题讨论】: