设计VB.NET UI动态或在编译时 [英] Design VB.NET UI Dynamically or at Compile Time

查看:260
本文介绍了设计VB.NET UI动态或在编译时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计一个程序,现在我已经遇到一个用户界面问题。我想有一大堆不同的屏幕,但我不希望有使用20种不同形式的(我是pretty的肯定是不好的做法反正),我不想放下所有的控制同时在设计,因为这样的事情会导致混乱。我不得不运行在启动子,将动态生成所有我需要的所有正确的坐标,并设置控件,然后倾人需​​要一个特定的屏幕变成一个小组的那些的想法。然后,我回到面板的ArrayList,并拉出正确的面板附加到表单时我需要的画面。唯一的问题是,我的形式不会有它的控制任何隐性知识,所以我假设我将无法使用WithEvents就/手柄。*关键字在窗体类声明的处理程序(这是我'宁愿做)。我知道这听起​​来有点令人费解;我仍然在试图理解我在说什么:)如果任何人有什么方法比较好,或者有更好的一个,我还没有遇到过,让我知道什么想法。

I'm designing a program now and I've come across a UI issue. I want to have a bunch of different screens, yet I don't want to have to use 20 different forms (I'm pretty sure that's bad practice anyways), and I don't want to lay down all the controls at once in the designer because then things get messy. I had an idea of running a sub on startup that would dynamically generate all the controls I need with all the right coordinates and settings, and then dump al the ones needed for a specific screen into a Panel. Then I return an ArrayList of panels, and pull out the correct panel to attach to the form when I need that screen. The only problem is that my form will not have any implicit knowledge of its controls, so I'm assuming I wouldn't be able to use the WithEvents / Handles.* keywords to declare handlers in the form class (which is what I'd rather do). I know this sounds a little convoluted; I'm still trying to understand what I'm saying :) If anyone has any ideas about what way is better, or if there's a better one that I haven't come across, let me know.

推荐答案

你所谈论的事情是设计师(静态)的对的方案(动态)的UI代。这是不太流行的一种神圣的战争,因为有双方球迷的。您可以使用事件等,与这两种方法(因为设计师实际上产生code到底)。它是由你来决定。有在编程方法一些好处,但它通常需要更多的时间(尤其是第一次)。

The thing you are talking about is a designer (static) vs. programmatic (dynamic) UI generation. This is less popular kind of holy war since there are fans on both sides. You can use events etc. with both approaches (since designer actually generates code in the end). It's up to you to decide. There are some benefits in programmatic approach, but it usually requires more time (esp. first time).

查尔斯Petzold的是程序化的用户界面创建一个已知的球迷,你可以从中学到这本书例如(但坏书对C#在一般情况下,恕我直言)。

Charles Petzold is a known fan of programmatic UI creation, you can learn some tricks from this book for example (but bad book on C# in general, IMHO).

这篇关于设计VB.NET UI动态或在编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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