private void btnOk_Click(object sender, EventArgs e) { int index = (list.SelectedIndices.Count < 1 ? -1 : list.SelectedIndices[0] - 1); if (index > -1) SelectedProvider = providers[index]; this.Close(); }
public SelectProvider(Provider[] providers) { InitializeComponent(); this.providers = providers; foreach (Provider p in providers) list.Items.Add(p.Name); list.DoubleClick += delegate { btnOk_Click(null, null); }; }