I bind a ComboBox
with a data source it shows the datasource in the dropdown but I want a default selected value.
Example:
"Select" is selected by default like shown in this picture.
In my Case result are show like this
This is my code:
public void BindComboBoxItem()
{
try
{
ItemRepository repo = new ItemRepository();
List<Item> items = repo.GetAll();
cbxSelectItem.DataSource = items;
cbxSelectItem.DisplayMember = "Name";
cbxSelectItem.ValueMember = "Id";
}
catch (Exception ex)
{
MessageBox.Show(MessageResource.ErrorMessage, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}