private void FrmVendorInfo_Load(object sender, EventArgs e) { try { lstOfVendors = vendBL.GetVendors(); if (lstOfVendors.Count != 0) { var sortedState = (from ven in lstOfVendors where ven != null orderby ven.State ascending select ven.State).Distinct(); var statesName = sortedState.ToList(); cboState.DataSource = statesName; cboState.SelectedIndex = -1; } else { MessageBox.Show("No Vendors Found", "No Vendors Found", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception except) { MessageBox.Show(except.Message, except.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }