是否可以在visual studio 2012中的vb.net中将控件从一个表单拖动到另一个表单? [英] Is it possible to drag control from one form to another form in vb.net in visual studio 2012 ?

查看:74
本文介绍了是否可以在visual studio 2012中的vb.net中将控件从一个表单拖动到另一个表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

是否可以在运行时将控件从一个窗口拖放到另一个窗体?就像在设计时我们必须从工具框中拖放控件一样,就像我需要创建一样一个工具箱里面有10个按钮,主要形式我必须从工具箱中拖动按钮并放入主窗口,



i可以用相同的形式和代码可在此链接中找到 是否可以在visual studio 2012中的vb.net中将控件从一种形式拖动到另一种形式? [ ^ ]



但是我需要像设计一样在运行时如何工作。



注意:按钮形状不同另一种形式,如浮窗。





问候

Aravind

Hai
is it possible to drag and drop control from one to another form in run time ?Like in designg time we have to drag and drop controls from tools box,same like i need to create one tools box in that having 10 buttons,and in main form i have to drag the button from tools box and drop in main window,

i can do in same form and code is available in this link Is it possible to drag control from one form to another form in vb.net in visual studio 2012 ?[^]

but i need like desing time how it work same like in run time.

Note: buttons not in same form it will in another form like floating window.


Regards
Aravind

推荐答案

您可以在表单之间复制和粘贴控件,方法是突出显示它们(使用CTRL并单击或拖动它们围绕它们)并使用CTRL + C和CTRL + V,但我认为你不能拖放 - 这不是我真正需要或尝试的东西。



问题在于它只复制设计图面上的控件和属性:它不会设置任何复制任何代码的事件,因此复制的控件实际上不起作用。



更好的方法是在UserControl上创建按钮,并将其中一个添加到两个表单中 - 这样就可以轻松地对按钮的功能进行任何更改,并且它会自动反映在两种形式中。它还有助于将表单代码的大小降低到更易于管理的级别:我一直这样做,它确实有助于获得干净的代码!
You can copy and paste controls between forms, by highlighting them (either with CTRL and click or drag a box round them) and using CTRL+C and CTRL+V, but I don't think you can drag and drop - it's not something I've really needed or tried.

The problem is that that copies the controls and the properties on the design surface only: it doesn't set any events of copy any code behind them, so the controls as copied will not actually work.

A better approach mch be to create the buttons on a UserControl, and add one of those to both forms - that way it is easy to make any changes to the function of the buttons and it is automatically reflected in both forms. It also helps to keep the size of a form code down to more manageable levels: I do it all the time, and it really helps with getting clean code out!


这篇关于是否可以在visual studio 2012中的vb.net中将控件从一个表单拖动到另一个表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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