1
我处理两个组合框丝毫遵循代码:密钥值对组合框的.text后保存在数据库
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中的值。 我该怎么做?
完美!非常感谢你 ! – Disaji