private void dgvJournalEntries_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //selection of combo box List<UDT.MgmtJournalEntryEnterprise> LstCompanyFiltersGrdOpr = this.bsEnterpriseCompanyFIlter.DataSource as List<UDT.MgmtJournalEntryEnterprise>; if (dgvJournalEntries.Columns[dgvJournalEntries.CurrentCell.ColumnIndex].Name == "CompanyFilters") { ComboBox combo = e.Control as ComboBox; if (combo != null) { // Remove an existing event-handler, if present, to avoid // adding multiple handlers when the editing control is reused. combo.DropDown -= new EventHandler(combo_DropDown); // Add the event handler. combo.DropDown += new EventHandler(combo_DropDown); } } } //And for Binding List void combo_DropDown(object sender, EventArgs e) { List<UDT.MgmtJournalEntryEnterprise> LstCompanyFiltersGrdOpr = this.bsEnterpriseCompanyFIlter.DataSource as List<UDT.MgmtJournalEntryEnterprise>; ComboBox combo = sender as ComboBox; combo.BeginUpdate(); int currentColIndex = dgvJournalEntries.CurrentCell.ColumnIndex; int currentRowIndex = dgvJournalEntries.CurrentCell.RowIndex; string preColumnCompanyValue = dgvJournalEntries[currentColIndex - 1, currentRowIndex].Value.ToString(); var CompanyFilterList = LstCompanyFiltersGrdOpr.Where(X => X.CompanyName == preColumnCompanyValue).SelectMany(X => X.tEDJFilterList).ToList(); if (CompanyFilterList.Count() > 0) { combo.DataSource = CompanyFilterList.Select(C => C.FName).ToList(); } combo.EndUpdate(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)