protected override void OnCellClick(DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { var ruleRowModel = SelectedItem as RuleRowModel; if (ruleRowModel == null) { return; } List <string> items = EnumTools <Rule.RuleType> .GetDisplayValues(typeof(Rule.RuleType)).ToList(); string current = ruleRowModel.TypeOfRule; string propertyName = ruleRowModel.GetName(() => ruleRowModel.TypeOfRule); _comboEditor.Show_Combobox(e.RowIndex, e.ColumnIndex, items, current, ruleRowModel, propertyName); return; } if (e.ColumnIndex == 2) { _grid.BeginEdit(true); } base.OnCellClick(e); return; }
protected override void OnCellClick(DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { var rowModel = SelectedItem as TransactionRowModel; AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded(); _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories); Transaction tempTransaction = new Transaction(); string propertyName = tempTransaction.GetName(() => tempTransaction.Category); if (null != eventCategories.Categories) { List <string> categoriesName = eventCategories.Categories.Categories.Select(c => c.Name).ToList(); string current = categoriesName.FirstOrDefault(); _comboEditor.Show_Combobox(e.RowIndex, e.ColumnIndex, categoriesName, current, rowModel, propertyName); } } if (e.ColumnIndex == 3) { var rowModel = SelectedItem as TransactionRowModel; string selectedCategory = rowModel.Category; if (selectedCategory.IsNotNull()) { AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded(); _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories); Category category = eventCategories.Categories.Categories.FirstOrDefault(i => i.Name == selectedCategory); List <string> subCategories = category.SubCategories.Select(s => s.Name).ToList(); Transaction tempTransaction = new Transaction(); string propertyName = tempTransaction.GetName(() => tempTransaction.SubCategory); string current = subCategories.FirstOrDefault(); _comboEditor.Show_Combobox(e.RowIndex, e.ColumnIndex, subCategories, current, rowModel, propertyName); } } }