int count,x,y;
count = 1; //此变量数量根据需要随时改变,姑且默认为1吧
x = 8; y = 5;
public class TRtGraphic
{
public Panel ChlPanel = new Panel();
public Panel[,] CellSub = new Panel[x, y];
}
public static TRtGraphic[] RtGraphic = new TRtGraphic[count];
RtGraphic = new TRtGraphic[count ] ; for (int P = 0; P < count ; P++)
{
RtGraphic[P].ChlPanel = new Panel(); RtGraphic[P].ChlPanel = new Panel();
RtGraphic[P].ChlPanel.Width = 800;
RtGraphic[P].ChlPanel.Height = 600;
RtGraphic[P].ChlPanel.Left = 8;
RtGraphic[P].ChlPanel.Top = 8; for (int i = 0; i < 8; i++)
for (int j = 0; j < 5; j++)
{
RtGraphic[P].CellSub [i, j] = new Panel();
RtGraphic[P].CellSub[i, j].Parent = RtGraphic[P].ChlPanel;
}
}一运行到RtGraphic[P].ChlPanel = new Panel();
这就出错.如果把class换成struct连编译都不能通过.
解决方案 »
- string
- 子线程中获取contextMenu的sourceControl
- DataGridView 基础问题
- 如何实现屏幕区域抓图,而且按区域大小的实际像素存BMP
- 菜鸟问题:请问如何在c#中调用另一个应用程序(.exe 带参数)
- 如何将string转化为一个控件名称,并可以对该控件赋值.
- 怎么样发邮件?
- 自定义控件的ParentControl特性具体是怎么一回事
- 怎么创建一个有多个sheet的EXCEL
- 怎么找不到System.Runtime.Remoting.Channels.Http命名空间(有点急)
- 刚编译了一个由VB.NET转换成C#的工程组,遇到了一些错误和警告,特献上100求助!
- 请问如何打印FORM
count = 1; //此变量数量根据需要随时改变,姑且默认为1吧
x = 8; y = 5;
public class TRtGraphic
{
public Panel ChlPanel = new Panel();
public Panel[,] CellSub = new Panel[x, y];
}
public static TRtGraphic[] RtGraphic = new TRtGraphic[count]; for(int i =0;i<count;i++)
{
数组还没有赋值, 在下面就不能访问,
RtGraphic[i] = new TRtGraphic[count] ;
}
for (int P = 0; P < count ; P++)
{
RtGraphic[P].ChlPanel = new Panel(); RtGraphic[P].ChlPanel = new Panel();
RtGraphic[P].ChlPanel.Width = 800;
RtGraphic[P].ChlPanel.Height = 600;
RtGraphic[P].ChlPanel.Left = 8;
RtGraphic[P].ChlPanel.Top = 8; for (int i = 0; i < 8; i++)
for (int j = 0; j < 5; j++)
{
RtGraphic[P].CellSub [i, j] = new Panel();
RtGraphic[P].CellSub[i, j].Parent = RtGraphic[P].ChlPanel;
}
}
count = 1; //此变量数量根据需要随时改变,姑且默认为1吧
x = 8; y = 5;
public class TRtGraphic
{
public Panel ChlPanel = new Panel();
public Panel[,] CellSub = new Panel[x, y];
}
public static TRtGraphic[] RtGraphic = new TRtGraphic[count]; for(int i =0;i <count;i++)
{
数组还没有赋值, 在下面就不能访问,
RtGraphic[i] = new TRtGraphic() ;
} for (int P = 0; P < count ; P++)
{
RtGraphic[P].ChlPanel = new Panel(); RtGraphic[P].ChlPanel = new Panel();
RtGraphic[P].ChlPanel.Width = 800;
RtGraphic[P].ChlPanel.Height = 600;
RtGraphic[P].ChlPanel.Left = 8;
RtGraphic[P].ChlPanel.Top = 8; for (int i = 0; i < 8; i++)
for (int j = 0; j < 5; j++)
{
RtGraphic[P].CellSub [i, j] = new Panel();
RtGraphic[P].CellSub[i, j].Parent = RtGraphic[P].ChlPanel;
}
}
public struct TRtGraphic 我觉得用struct 比较简单,内存占用也比较小,可是上面的方式如果换成struct
这种表达式public Panel[,] CellSub = new Panel[x, y]; 就会出错.有没有更好的办法处理struct 中的字段?(如果处理一般的可变数组没问题,但只有加入panel或者label组件的声明,就会出错)