本文介绍了如何解决“已经做出了圆形对照参考".例外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向面板添加控件时出现以下异常.

循环控制参考.控件不能由其自身拥有或作为其父项.

代码:

I am getting the below exception while adding controls to panel.

A circular control reference has been made. A control cannot be owned by or parented to itself.

Code:

int yAxis = 0;
for (int i = stkNotificaiton.Count; i > 0; i--)
{ 
    Panel pnl = (Panel)stkNotificaiton.Pop();
    pnl.AutoSize = true;
    pnl.Location = new Point(0, yAxis);
    pnlNotification.Controls.Add(pnl);  // <-------------------Error is showing.
    yAxis = 48 * noofNewNotifications;
}



这里stkNotification是一个堆栈.
请帮助解决该问题.



here stkNotification is a stack.
Please help to solve this problem.

推荐答案


这篇关于如何解决“已经做出了圆形对照参考".例外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 01:57