in Program.cs I add this code:
- services.AddDbContext
(context => context.UseSqlServer(constr)); - services.AddScoped
(); - services.AddScoped
();
in MDIForm I add this code:
- private readonly IClassService classService;
- private readonly ICategoryService categoryService;
- public MdiForm(IClassificationService classificationService, ICategoryService categoryService){
- this.classService = classService;
- this.categoryService = categoryService;}
then to show a category from MDI I do this code. But in order to add the classService from CategoryForm to Classification, it should be a part of CategoryForm.
from MDI Form to show CategoryForm:
- var categoryForm = new frmCategory(classService, categoryService);
- categoryForm.ShowDialog();
- from CategoryForm to show ClassForm:
- var classForm = new frmClass(classService);
- classForm .ShowDialog();

Mario ScheerenRank #1,371 · 1.2K reputationPosted Mar 8, 2021, 12:31 AM EST
Mario ScheerenRank #1,371 · 1.2K reputationPosted Mar 2, 2021, 1:29 PM EST
Geni Lou121 reputationPosted Mar 7, 2021, 11:34 PM EST