public AddSpans(List <Span> spans, int index) { InitializeComponent(); Spans = spans; EditingSpan = Spans.GetRange(index, 1).Single(); PossibleProfiles = EditingSpan.PossibleProfiles; textTitle.Text = EditingSpan.Title; textLength.Text = EditingSpan.Length.ToString(); foreach (Profile profile in Main.Profiles.Where(p => !PossibleProfiles.Contains(p))) { comboProfiles.Items.Add(profile); } dataGridProfiles.Columns.Add("Profile", "Profile"); dataGridProfiles.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; foreach (Profile profile in PossibleProfiles) { dataGridProfiles.Rows.Add(profile); } buttonCreateOrModify.Text = "Modify"; buttonCreateOrModify.Click += buttonModifySpan_Click; comboProfiles.SelectedIndex = 0; }
private void buttonRemoveProfile_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection rows = dataGridProfiles.SelectedRows; List <Profile> backupList = new List <Profile>(PossibleProfiles); foreach (DataGridViewRow row in rows) { PossibleProfiles.Remove(backupList.GetRange(row.Index, 1).Single()); } comboProfiles.Items.Clear(); foreach (Profile profile in Main.Profiles.Where(p => !PossibleProfiles.Contains(p))) { comboProfiles.Items.Add(profile); } dataGridProfiles.Rows.Clear(); foreach (Profile profile in PossibleProfiles) { dataGridProfiles.Rows.Add(profile); } comboProfiles.SelectedIndex = 0; }