UserControl Designer模式失败? [英] UserControl Designer mode failure?

查看:72
本文介绍了UserControl Designer模式失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


当我的UserControl打开设计模式时,我的消息框有错误:


控件System.Windows .Forms.UserControl在设计器中抛出了一个未处理的异常并被禁用。


异常:已添加项目。键入字典:'tableLayoutPanel2 [System.Windows.Forms.TableLayoutPanel],BorderStyle:System.Windows.Forms.BorderStyles.None'要添加的键:'tableLayoutPanel2 [System.Windows.Forms.TableLayoutPanel],BorderStyle:System.Windows。 Forms.BorderStyles.None'


堆栈跟踪:


在System.Windows.Forms.UserControl.WndProc(消息& m)


..


问题背景说明:


VS2005,C#


I我使用Tabcontrol设计UserControl(3个标签页),在每个标签页上我使用TableLayoutPanel自动排列标签和输入控件两列。


在某些单元格中我使用Panel放置多于1个控制到单元格。


但是经过一段时间后,Designer会在设计窗口中显示错误消息框和带有错误描述的红色边框。


我尝试了什么要做的事情:


我试图找到.designer.cs中的重复插入在tableLayoutPanel2的TabControl组件集合中 - 找不到重复项。


当我试图在InitializeComponent中注释.Component.Add指令时 - 设计器按预期显示我的控件设计 - 没有tableLayoutPanel2及其中的所有控件。


然后我用"红色边框"打开设计师。和错误(我恢复.Component.Add命令),在属性窗口中选择"坏" tableLayoutPanel2。进入设计器出现tableLayoutPanel2边框并移动图标。当我点击移动图标时,tableLayoutPanel2显示在UserControl上的错误描述。


我将tableLayoutPanel2剪切到剪贴板并刷新设计窗口 - 它显示正常。在我选择tableLayoutPanel2所在的TabPage并将其粘贴到TabPage之后。它正在工作,但是..我花了一些时间来记住并重置所有事件处理程序到panelTableLayout中的所有控件。它不是很有趣而且非常快 - 因为tableLayoutPanel上有很多控件,有许多事件处理程序。


这种情况重复了一些。


我无法理解这种设计模式故障的真正原因。


问题:


有没有办法防止这种情况发生?



解决方案

< blockquote>

嗨谢尔盖,


你有没有解决过这个问题?我遇到了使用VB.NET的相同问题,用户控件使用tab控件,其中包含使用tablelayoutpanel的tabpages。


我很难过。您是否偶然使用任何数据绑定?


Hello,

When open design mode for my UserControl I have the message box with error:

The control System.Windows.Forms.UserControl has thrown an unhandled exception in the designer and has been disabled.

Exception: Item has already been added. Key in dictionary: 'tableLayoutPanel2 [ System.Windows.Forms.TableLayoutPanel], BorderStyle: System.Windows.Forms.BorderStyles.None' Key being added: 'tableLayoutPanel2 [ System.Windows.Forms.TableLayoutPanel], BorderStyle: System.Windows.Forms.BorderStyles.None'

Stack trace:

at System.Windows.Forms.UserControl.WndProc(Message& m)

..

Problem context description:

VS2005, C#

I've design UserControl with Tabcontrol (3 tabpages) and on each tabpage I use TableLayoutPanel for auto arrange labels and input controls in two columns.

In some cells I use Panel to place more then 1 control to cell.

But after some time the Designer show me error message box and red border with error description inside design window.

What I try to do:

I tried to find in .designer.cs duplicated insertion in TabControl Component collection of tableLayoutPanel2 - duplicate not found.

When I tried to comment the .Component.Add instruction in InitializeComponent - the designer show the my control design as expected - WITHOUT the tableLayoutPanel2 and all controls inside it.

Then I open the designer with "red border" and error (I restore .Component.Add command), select in Properties window "bad" tableLayoutPanel2. Into designer appear tableLayoutPanel2 border and move icon. When I click on move icon the tableLayoutPanel2 is shown upon error description on the UserControl.

I cut tableLayoutPanel2 into clipboard and refresh the design window - it's shown fine. After I select the TabPage where tableLayoutPanel2 was and paste it into TabPage. It's working, but.. I've spent some time to remember and reset all event handlers to all controls in the panelTableLayout. It's not very funny and very fast - cause there are many controls on the tableLayoutPanel with many event handlers.

This situation was repeated some times.

I can't understand real reason for such Designer mode faults.

Question:

Is there the way to prevent this situations?

 

 

解决方案

Hi Sergei,

Did you ever solve this problem? I'm experiencing the same issues using VB.NET, user control with tab control that contains tabpages that use the tablelayoutpanel.

I'm stumped. Are you by chance using any databinding with this?


这篇关于UserControl Designer模式失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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