【发布时间】:2015-11-13 14:14:42
【问题描述】:
我需要帮助来修复我的代码:
for (int P = 0; P < DataGridView.Rows.Count - 0; P++)
{
TNTDATADataContext Context = new TNTDATADataContext();
var q = (from C in Context.Customers
where C.Code == Code.Text && C.CompanyId == CompanyId
join TP in Context.TourProgrammes on C.PackageId equals TP.Id
select new { TP.DayId, TP.FromCityId, TP.ToCityId, TP.Programme }).First();
DataGridViewComboBoxCell DaysComboBoxCell = (DataGridViewComboBoxCell)DataGridView.Rows[P].Cells[0];
DaysComboBoxCell.Value = (object)q.DayId;
DataGridViewComboBoxCell FromCityComboBoxCell = (DataGridViewComboBoxCell)DataGridView.Rows[P].Cells[1];
FromCityComboBoxCell.Value = (object)q.FromCityId;
DataGridViewComboBoxCell ToCityComboBoxCell = (DataGridViewComboBoxCell)DataGridView.Rows[P].Cells[2];
ToCityComboBoxCell.Value = (object)q.ToCityId;
DataGridView["Programme", P].Value = (object)q.Programme;
}
这段代码运行良好,并在我已通过代码绑定的 DataGridViewComboBoxCell 中绑定了一个值。
有第一个快照
在那里您可以看到一个旅游计划区域,其中 DataGridView 中有 3 个 DataGridViewComboBoxCell 这是加载客户详细信息之前的快照现在我在客户代码TextBox 中输入代码后加载了客户旅游详细信息 归档显示所有详细信息但未在 DataGridView 中显示其余的旅游节目列表,它在第二个快照中显示结果
我想要像我手动制作的第三个快照这样的结果,以便您了解在加载客户游览详细信息后我如何想要结果
【问题讨论】:
标签: c# winforms linq datagridview datagridviewcomboboxcell