I have started to develop a support tool for an old legacy system that is no longer maintained but still needed for the foreseeable future. The legacy system offers few, clunky and error prone methods for basic tasks such as handling users, rules, data imports and settings. The Tool I am developing will be used by the inhouse support team.

I’m using panels to group related tasks together. I intend to load each panel into a TabControl on user request. The main form have a few user settings that affects/ all panels. A panel might perform a task that other panels need to aware of.

Question TL:DR

How can the MainForm be made aware that Panel A have made a significant change that other panels might be interested in?

How can a panel receive information from MainForm?

My thoughts so far:

The MainForm could get information from each Panel by subscribing to custom events (such as a UsersUpdatedEvent). But how to do the other way around since a Panel does not “know” the parent form?

Use example:
Homer wants to add a user and a new rule for company “Duff Beer”. He opens the application and selects “Duff beer” from a dropdown list. He then clicks on a “User” toolstrip icon and the user panel opens in a tab. Homer creates user “Lisa” and then switches over to “Rules” panel and creates a new rule that is owned by Lisa.

Bonus question:
I would also like each panel to be able to add menu items to the MainForm Menustrip. Now that I think about it, the application is a bit like a very very lightweight Visual studio. With tabs and menus and toolbars that change depending on whtat the user is watching.

1

First off, don’t use Panels to group related tasks. Use UserControls. I used panels to group controls on my first WinForms application, and it turned into a horrible monstrosity, worthy of appearing on TDWTF. Just…don’t do it.

Instead, use UserControls. These are kind of like Windows, but are hosted inside of a container, similar to a Button or ComboBox. Normal function calls are used for MainForm to UserControl communication. Events are used for UserControl to MainForm communication.

For example, you might have a UserControl called CreateNewUser. It would contain a text box for the new user’s name and a button to create a new user’s name. It would also need a way of notifying the MainForm that the button was clicked.

The individual UserControls do not need to know about the MainForm. All they need to do is provide public (usually custom) events that their parent can then use. CreateNewUser does not need to care what created it. All CreateNewUser needs to do is let its parent know when the user has created a new user.

To answer your question..

How can a panel [UserControl] receive information from MainForm?

The panel [UserControl] will provide public functions / methods that the MainForm can call. The code behind the UI in WinForms is very similar to plain old C# classes. In fact, they are. They can have public methods and properties that anyone can call.

Here’s the MSDN for WinForms UserControls: https://msdn.microsoft.com/en-us/library/aa302342.aspx

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật