运行时动态对象创建和关系 [英] runtime Dynamic object creation and relations

查看:66
本文介绍了运行时动态对象创建和关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里使用的是什么技术?



我想这样做..

http://www.youtube.com / watch?v = W6HMUmrL-Hk

使用的算法是什么?或api谢谢你

What is the used here technology ?

I want to do it..
http://www.youtube.com/watch?v=W6HMUmrL-Hk
What is the used algorithm ? or api thank you

推荐答案

没有动态创建对象的问题。从某种意义上说,动态这个词意味着,它们总是动态创造,而不是任何其他方式。



这是我一直给出的建议:看看现有的Visual Studio设计师做了什么。使用Forms,设计器会自动生成一些代码,这些代码同时起到源代码的作用。当您使用设计器打开表单或用户控件时,将读取现有代码,然后您可以使用设计器对其进行修改。您只需打开在该窗体或用户控件的解决方案资源管理器节点下找到的源代码文件即可。如果您不知道如何编写代码但知道如何使用设计器,请使用设计器进行示例,然后查看自动生成的代码。



特别是,它会向您显示生成和添加控件。假设您已经有一些父控件,例如表单或面板。现在您向其添加新控件,例如:

There is no a problem of "dynamic creation of objects". In that sense of the word "dynamic" you meant, they are always created dynamically, not any other way.

This is the advice I always give: just look at what existing Visual Studio designer does. With Forms, designer automatically generates some code which serves a role of the source code at the same time. When you open a form or a user control with the designer, existing code is read, and then you can modify it using the designer. All you need to do it to open that source code file found under the Solution Explorer node of that form or user control. If you don't know how to write some code but know how to do it with the designer, make a sample with the designer and then look at the auto-generated code.

In particular, it will show you the generation and adding control. Let's assume you already have some parent control, such as a form or a panel. Now you add new controls to it, for example:
Panel parent = //... let's assume you already have it
ComboBox comboBox = new ComboBox();
Label label = new Label();
label.Text = "Some &Text";
// ... set Left, Top, Dock, Padding
// ... in some controls, Width or Height or both...
// ... other properties...
// now, adding:
parent.Controls.Add(label); // a child has been added
comboBox.Parent = parent; // an equivalent way



等等on ...



-SA


这篇关于运行时动态对象创建和关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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