Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping code tidy on windows forms app with tabs

I'm currently developing an Windows Forms application in C# which will make use of tabs for the GUI. The problem I'm facing though is that the code is becoming untidy. The reason is that the code for GUI components (such as button clicks) resides on the main form code. So I'm looking for a way to still handle all the GUI interactions the same way but separate the code in a logical way (e.g. different files). Like having button1_click() reside in another file but work the same way as before. Thanks :)

like image 788
TGO Avatar asked Jan 18 '13 17:01

TGO


1 Answers

You can place each "Tab" into its own UserControl, and handle the events there instead of all within the main form.

As tabs typically each represent something "distinct", this is often fairly simple to implement, and helps clean up your code.

like image 80
Reed Copsey Avatar answered Sep 29 '22 06:09

Reed Copsey