如何在窗体之间共享UI设计? [英] How to share UI design between window forms?

查看:91
本文介绍了如何在窗体之间共享UI设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,



我的项目中的.NET C#窗口有问题。

我有很多不同的窗口形式我的项目,其中许多看起来很相似。



目前,我为每个窗口创建单独的控制项和代码。

这意味着每当我遇到错误或需要实现新功能时,我需要多次修改UI设计和源代码。我需要多次重复编码工作!这让我真的很累。



有没有办法只实现一次UI设计并在窗体之间共享?



如果您有任何疑问,请随时与我联系。谢谢!



Eric Fang



我尝试了什么:



我尝试实现一些全局函数来改善这一点,但它没有太多帮助。

Dear Sir,

I have a problem with my .NET C# window from project.
I have many different window forms in my project, and many of them looks similar.

Currently, I create individual control items and code for each window from.
That means, I need to modify the UI design and the source code many times whenever I have bugs or I need to implement new features. I need to repeat the coding work many times! That makes me really tired.

Is there a way to implement the UI design only once and share it between window forms?

Please feel free to contact me if you have any question. Thank you!

Eric Fang

What I have tried:

I try to implement some global functions to improve this, but it does not help too much.

推荐答案

这很复杂,因为我们无法看到你的表格,或者对他们的作品有任何感觉,或者实际上有多少相似性。



但是如果你在多个地方有相同的代码,有几种方法可以减少它。

第一种方法是声明一个实现共享功能的基本形式,并派生出你的其他形式从那以后。这样,您可以修改公共代码和控件一次,并自动传播到派生表单。



第二种方法是仔细查看您的内容将它复制并抽象到UserControls中,您可以在多个表单中重复使用它们。同样,这意味着你有一个代码库,你可以修改它,并使用它更新所有表格。



我使用UserControls非常多,两者都是分享通用控件功能和外观,并分隔我的代码,使表单代码库更小,更容易使用。



什么对你有好处? Dunno - 我们无法访问您的应用程序!
That's complicated, because we can't see your forms, or get any feel for what they do, or how much "similarity" there actually is.

But if you have the same code in multiple places, there are a couple of ways you can reduce that.
The first way is to declare a "base form" which implements the shared functionality, and derive your other forms from that. That way, you modify the common code and controls once, and it automatically "propagates" to the derived forms.

The second way is to look closely at what you are duplicating and abstract that into UserControls which you reuse across a number of forms. Again, this means that you have a single code base which you can modify and which updates all the forms using it.

I use UserControls quite a lot, both to "share" common control functionality and appearance, and to "compartmentalise" my code and make the form code base smaller and easier to work with.

What's good for you? Dunno - we don't have any access to your app!


这篇关于如何在窗体之间共享UI设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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