将现有用户控件添加为 TabControl 中的 TabPage
我有几个 Visual Studio 2003 c# 项目,每个项目都包含一个“用户控件”项目,我从文本框中读取一些输入数据,在单击按钮时执行一些计算并在文本框中显示结果。这些项目的输出是 dll 文件。
问题是我想创建一个带有 TabControl 项的单独项目,并将现有项目中的“用户控件”项添加为 TabPages。保持“用户控制”项的现有事件处理程序完好无损非常重要。生成的项目的输出也应该是一个 dll 文件。我该怎么做? 也许有人知道获得相同结果的不同方法?
非常感谢! 彼得
I have several Visual Studio 2003 c# projects, each of them containing a "User Control" item where I read some input data from text boxes, perform some calculations when a button is clicked and display the results in text boxes. The outputs of these projects are dll files.
The thing is I would like to create a separate project with a TabControl item and add the "User Control" items from my existing projects as TabPages. It is important to keep intact the existing event handlers of my "User Control" items. The output of the resulting project should also be a dll file. How do I do it?
Maybe somebody knows a different way to obtain the same result?
Thank you very much!
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是一个 winforms 应用程序,那么您需要执行几个步骤:
1) 将对每个 UserControl 项目 DLL 的引用添加到您的应用程序中。
2) 将控件添加到选项卡页。有两个选项:
a) 在运行时通过代码添加控件。
b) 在设计时将控件添加到窗体中(我更喜欢这种方法,但两者都是正确的)。为此,请执行以下操作:打开要在其上放置控件的窗体,打开工具箱(如果尚未打开),然后将每个项目 DLL 拖到工具箱上。这应该在工具箱中创建与您的用户控件相匹配的项目以供选择。为每个用户控件创建一个选项卡,然后将相应的项目从工具栏拖动到选项卡;这应该在选项卡中创建用户控件。
If this is a winforms application, then you need to take a couple of steps:
1) Add references to each of the UserControl project DLLs to your application.
2) Add the controls to your tab pages. There are two options:
a) Add the control through code at run time.
b) Add the control to the form at design time (I prefer this method, but both are correct). To do this: open the form that you want to place the controls on, open the toolbox, if it isn't already, then drag each of the project DLLs onto the toolbox. This should create items in the toolbox to chose from that match your usercontrols. Create a tab for each user control, then drag the appropriate item from the toolbar to the tab; this should create the user control in the tab.