我的組無法讓此組合框和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