所以我用如下复选框进行了简单的搜索:
这是你的密码 sort
按钮:
private void sort_btn_Click(object sender, EventArgs e)
{
if (cntr_check.Checked == true && pos_check.Checked == true)
{
var query = from o in this.leodata.main
where o.country.Contains(cntr_combo.Text) && o.position.Contains(pos_combo.Text) && o.price <= price_bar.Value
select o;
mainBindingSource.DataSource = query.ToList();
}
else if (cntr_check.Checked == true && pos_check.Checked == false)
{
var query = from o in this.leodata.main
where o.country.Contains(cntr_combo.Text) && o.price <= price_bar.Value
select o;
mainBindingSource.DataSource = query.ToList();
}
else if (cntr_check.Checked == false && pos_check.Checked == true)
{
var query = from o in this.leodata.main
where o.position.Contains(pos_combo.Text) && o.price <= price_bar.Value
select o;
mainBindingSource.DataSource = query.ToList();
}
else
{
var query = from o in this.leodata.main
where o.price <= price_bar.Value
select o;
mainBindingSource.DataSource = query.ToList();
}
}
现在我需要做一个高级搜索:
我试着这样做:
private void button1_Click(object sender, EventArgs e)
{
if (spain_check.Checked == true)
{
var query = from o in this.leodata.main
where o.country.Contains(spain_check.Text)
select o;
mainBindingSource.DataSource = query.ToList();
}
if (france_check.Checked == true)
{
var query = from o in this.leodata.main
where o.country.Contains(france_check.Text)
select o;
mainBindingSource.DataSource = query.ToList();
}
}
哪里 spain_check
以及 france_check
是我的复选框。我有一个想法,我会检查每一个复选框,如果 Checked == true
然后我将从mysql添加新行。但它不断更新我的表,而不是添加新行。
我该怎么做?
暂无答案!
目前还没有任何答案,快来回答吧!