每个代码段都在一个单独的文件中 [英] Each section of code in a separate files

查看:73
本文介绍了每个代码段都在一个单独的文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个包含不同标签的表单。每个标签都是"新部分"。并且有很多代码。


我是否有办法将每个代码段放在一个单独的文件中?


否则它会变得很麻烦使用Form1.cs中的所有代码。


类似于:


默认选项卡==>文件1(Form1.cs)

第二个标签==>文件2(Somefile2.cs)

第三个标签==>文件3(Somefile3.cs)


解决方案


你可以将它分成不同的部分类,或者,恕我直言更好,为选项卡中调用的任务创建类,为每个部分创建自己的UserControl与所有控件[和其他逻辑],然后将这些UserControls放到TabControl的Tabs


问候,


 的Thorsten


I will need a form with different tabs. Every tab is a "new section" and has a lot of code.

Is there a way I could have each section of code in a separate files?

Otherwise it gets så messy with all the code in Form1.cs.

Something like:

Default tab ==> file 1 (Form1.cs)
Second tab ==> file 2 (Somefile2.cs)
Third tab ==> file 3 (Somefile3.cs)

解决方案

Hi,

you could separate it into different partial classes, or, IMHO better, create classes for the tasks that are called in the Tabs, for each section create its own UserControl with all Controls [and additional logic] and just put those UserControls to the Tabs of the TabControl.

Regards,

  Thorsten


这篇关于每个代码段都在一个单独的文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆