一般控件的遍历是foreach(Control con in this.controls) Statement
因为我写的是一个静态函数需要遍历,所以就没有this。用该对象名:frmPutInPexieElements
foreach(Control con in frmPutInPexieElements. 此时就没有controls这个变量了,只有controlcollection。但是controlcollection无法遍历。求指导
...全文
11511打赏收藏
C# 控件遍历怎么会出现这样的问题?
一般控件的遍历是foreach(Control con in this.controls) Statement 因为我写的是一个静态函数需要遍历,所以就没有this。用该对象名:frmPutInPexieElements foreach(Control con in frmPutInPexieElements. 此时就没有controls这个变量了,只有controlcollection。但是controlcollection无法遍历。求指导
我可能有些地方有问题。我把可能有问题的地方写出来
以下是program里面的:
Form frmPutInInsideOrientalElements = new frmPutInInsideOrientalElements();
Form frmPutInObjCoordinates=new frmPutInObjCoordinates ();
Form frmPutInOutSideOrientalElements=new frmPutInOutSideOrientalElements ();
//Form frmPutInPixelsCoordinates = new frmPutInPixelsCoordinates();
Application.Run(new frmPutInPixelsCoordinates());
以下是另外一个类里面的(BeforeCount)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows .Forms;
namespace 摄影测量后方交会
{
class BeforeCount
{
private static bool [] aCount=new bool[4];
private static Form frmPutInInsideOrientalElements = new frmPutInInsideOrientalElements();
static public void MakeAChange()
{
for (int i = 0; i < 4; i++)
{
if (aCount[i] == true)
{
}
}
}
static public void MakeAChange(int i)
{
switch (i)
{
case 0: foreach (Control con in**就这里出问题了***)
}
}
}
}