Pay attention to the operation of Collection.

zhaozj2021-02-16  81

Write a program, used to move my User Control from a panel to another PANEL, as follows

Private Void MoveViewers (Infolist SourceList, Infolist TargetList)

{

Foreach (Object Viewer in Source.controls)

{

IF ((InfoViewer) .Checker.checked)

TargetList.controls.add (InfoViewer);

}

} Who knows, actually an error, depressed, thinking about it, should be controls that foreac can not find the object. Modified as follows: Private Void MoveViewers (Infolist SourceList, Infolist TargetList)

{

Queue queqe = new queue ();

Foreach (Object Viewer in Source.controls)

{

IF ((InfoViewer) .Checker.checked)

Quece.enqueue (viewer);

}

While (queqe.count! = 0)

{

TargetList.controls.add ((InfoViewer) quece.dequeue ());

}

}

Bug repair is easy to use.

I am sigh, OOP is accidentally, and an idea who wants to be of course causes a BUG, ​​it's too horrible.

转载请注明原文地址:https://www.9cbs.com/read-16110.html

New Post(0)