使用VB.Net在运行时进行UI设计 [英] UI design at runtime using VB.Net

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

问题描述

亲爱的,

任何人都可以解释(使用示例代码)如何使用VB.Net在运行时使用控件创建UI。例如如果用户需要在表单上的特定X,Y位置(基于拖放)添加2个标签和1个文本框,他应该能够这样做。其他一些用户想在特定坐标上添加5个标签;他应该能够做到这一点。



提前谢谢..

解决方案

示例代码已经在你的手指下,你只需要发现它。



我会更好地解释你找到所有必需技术的非常有效的方法。



首先,您应该了解没有不在运行时或在设计时创建控件。 无论你做什么,控件都是总是在运行时间创建。当然,你需要了解真正发生的事情,而不是仅仅使用设计师而不理解精华东西的。设计器只是一个可视化工具,用于生成一些在运行时实际执行的代码。 (你应该谨慎使用设计师;过度使用它是一个常见的问题,导致大量重复的手工工作而没有适当的重用和支持。)



那说,您可以执行以下操作:使用设计器以您希望的方式创建控件及其布局。完成后,您将看到一些自动生成的代码;它将被放置为表单节点的子节点。打开生成的代码,学习如何正确对待同一件事。 那就是你在问题中要求的那个示例代码。就是这样。



-SA

Dear all,
Can any one explain(with sample code) how to create UI with controls at runtime using VB.Net. e.g. if user needs to add 2 labels & 1 textbox at a particular X,Y position(Based on Drag-drop) on the form he should be able to do it. Some other user want to add 5 labels at specific coordinate; he should be able to do it.

Thanks in advance..

解决方案

The sample code already lies under your fingers, you just need to spot it.

I'll better explain you a pretty productive method of finding out all required techniques.

To start with, you should understand that there is no creation of controls "not in runtime", or during design time. No matter what you do, the control are always created during runtime. And of course, you need to learn what really happens, instead of using just the designer without understanding the essence of things. The designer is merely a visual tool used to generate some code which is actually executed during runtime. (And you should use the designer with care; overusing it is a usual problem leading to a lot of repetitive manual work without proper reuse and supportability.)

That said, here is what you can do: create the controls and their layout the way you want using the designer. When you are done, you will see some auto-generated code; it will be placed as a child node of the form node. Open the generated code and learn how to right the same thing. That would be the same very "sample code" you requested in your question. That's all.

—SA


这篇关于使用VB.Net在运行时进行UI设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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