G
Guest
The compiler complains that zero is not acceptable value for selectedIndex.
What I am doing is loading up the combo box with the data from a dataset and
then setting the SelectedIndex value to zero thus forcing the first record to
be selected.
This is an untyped data set and unbound...
Here is a snippet:
private void frmCustomer_Load(object sender, EventArgs e)
{
BindCustomerComboBox();
cbFindName.SelectedIndex = 0;
customer =
CustomerDB.GetCustomer(cbFindName.SelectedValue.ToString());
ShowCustomerData();
DisableAddEditMode();
}
private void BindCustomerComboBox()
{
cbFindName.SelectedIndexChanged -=
new System.EventHandler(cbFindName_SelectedIndexChanged);
DataTable customersTable = CustomerDB.GetCustomers();
cbFindName.DataSource = customersTable;
cbFindName.DisplayMember = "cuLastName";
cbFindName.ValueMember = "cuCustomerID";
cbFindName.SelectedIndexChanged +=
new System.EventHandler(cbFindName_SelectedIndexChanged);
}
What I am doing is loading up the combo box with the data from a dataset and
then setting the SelectedIndex value to zero thus forcing the first record to
be selected.
This is an untyped data set and unbound...
Here is a snippet:
private void frmCustomer_Load(object sender, EventArgs e)
{
BindCustomerComboBox();
cbFindName.SelectedIndex = 0;
customer =
CustomerDB.GetCustomer(cbFindName.SelectedValue.ToString());
ShowCustomerData();
DisableAddEditMode();
}
private void BindCustomerComboBox()
{
cbFindName.SelectedIndexChanged -=
new System.EventHandler(cbFindName_SelectedIndexChanged);
DataTable customersTable = CustomerDB.GetCustomers();
cbFindName.DataSource = customersTable;
cbFindName.DisplayMember = "cuLastName";
cbFindName.ValueMember = "cuCustomerID";
cbFindName.SelectedIndexChanged +=
new System.EventHandler(cbFindName_SelectedIndexChanged);
}