Цикл всех bindingsources и всех наборов данных во всех открытых формах mdichildren
My project is c# WinForms. I have 2 forms in my project, one of them is a MdiParent form and I want to through its MdiChildren forms and if they have a BindingSource I want to make it endedit. And if they have a dataset I want to test it if haschanges or not. Thanks in advance for help. I tried this code
Что я уже пробовал:
foreach (Form frmm in Application.OpenForms) { foreach( Control c in frmm.Controls) { if (c is BindingSource) { c.endedit(); } } } foreach (Form frmm in Application.OpenForms) { foreach (Control c in frmm.Controls) { if (c is dataset) { if (c.HasChanges()) { MessageBox.Show("there are a unsaved data") } } } }