我的组无法让此组合框和datagridview相互交谈。应该发生的事情是,当你从组合框中选择一个名字时,任何带有技术ID的开放事件都应该出现。我们已经有了过滤器的工作,但我们似乎无法让两者相互交谈。这里是我们迄今的代码:使用组合框来获取要在DataGridView中显示的数据以过滤查询结果
public partial class frmIncidentMaintenance : Form
{
public Incident incident;
public frmIncidentMaintenance()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TechSupportEntities techSupport = new TechSupportEntities();
var customers = (from customer in techSupport.Customers
orderby customer.Name
select new { customer.CustomerID, customer.Name
}).Distinct();
cmbCustomersBindingSource.DataSource = customers.ToList();
cmbCustomersBindingSource.DisplayMember = "Name";
cmbCustomersBindingSource.ValueMember = "CustomerID";
var products = from customer in techSupport.Customers
from incident in customer.Incidents
where incident.TechID != null
where incident.DateClosed == null
select new
{
incident.ProductCode,
incident.TechID,
incident.Title,
incident.DateOpened,
incident.DateClosed,
incident.Description
};
dataGridView1.DataSource = products.ToList();
}
private void cmbCustomers_SelectedIndexChanged(object sender, EventArgs
e)
{
}
private void dataGridView_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
任何帮助,将不胜感激。
你必须把一些逻辑在cmbCustomers_SelectedIndexChanged,例如,使接收的参数(cmbCustomers的SelectedValue)的方法,然后调用它每次cmbCustomers触发事件的时间。 – JCM
像什么JCM?我和我的两个合作伙伴已经为此工作了两周,并且我们一直在SelectedIndexChanged事件处理程序中停滞不前。 – Venomsamurai