I have a LINQ query that retrieves rows from a dataset and binds it to a Winforms combobox:
namespace KimHongAutoAccessory.Forms
{
public partial class EngineFilter : Form
{
public EngineFilter()
{
InitializeComponent();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void EngineFilter_Load(object sender, EventArgs e)
{
this.engineFilterTableAdapter.Fill(this.manufacturerEngine.EngineFilter);
var manufacturers = (from m in manufacturerEngine.EngineFilter
select new { m.ManufacturerID, m.Manufacturer })
.Distinct().ToList();
cboManufacturerFilter.DataSource = manufacturers.ToArray();
cboManufacturerFilter.DisplayMember = "Manufacturer";
cboManufacturerFilter.ValueMember = "ManufacturerID";
}
}
}
But I want to add a union item to the combobox like the word “[All]”:
|-------|
|TOYOTA |
|-------|
|KUBOTA |
|-------|
|FORD |
|-------|
|[All] |
|-------|
Can anybody give me a trick?
Presumably your “(All)” item would have a special value for its ID so you know when it has been selected. Let’s assume its ID is -1.