一般控件的遍历是foreach(Control con in this.controls) Statement
因为我写的是一个静态函数需要遍历,所以就没有this。用该对象名:frmPutInPexieElements
foreach(Control con in frmPutInPexieElements. 此时就没有controls这个变量了,只有controlcollection。但是controlcollection无法遍历。求指导
因为我写的是一个静态函数需要遍历,所以就没有this。用该对象名:frmPutInPexieElements
foreach(Control con in frmPutInPexieElements. 此时就没有controls这个变量了,只有controlcollection。但是controlcollection无法遍历。求指导
解决方案 »
- 用C#编写一个可自动更新的小程序,使用Remoting技术
- C# XmlDocument.Load 路径问题
- 做一个算法, 能够将一个浮点数转换成整数. (不得使用.net中现成的算法, 或各数据类型的Parse方法)
- 为何不直接返回DataTable来用呢?
- 请教怎样用c++/cli封装c++的code,使其能被c#调用
- c#中对成员变量有多态性的说法吗?
- xml文件中有特殊符号时用load方法就出现异常
- 大家在公司用什么软件做bug跟踪的?
- 在线100分求助:如何控制。NET网页中报表的打印??
- C#中还有没有com组件的概念了?
- c# 中求50到100之间哪个数具有最多真因子
- javascript 数组如何转为C#的数组
以下是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**就这里出问题了***)
}
}
}
}
都静态了你this指向啥?
但是把frmPutInInsideOrientalElements输入后(我在BeforeCount里面定义过,并且分配了空间)就有.Controls
无论是frmPutInObjCoordinates还是frmPutInOutSideOrientalElements都不行