[英]TableLayoutPanel constructing an object for each cell
Hi I am working on ac# Windows Form design assignment. 嗨,我正在从事ac#Windows窗体设计任务。 Basically we have been supplied with most of the code to create a working board game similar to snakes and ladders. 基本上,我们已经获得了大部分代码,以创建类似于蛇和梯子的工作台游戏。 So far I have created a TableLayoutPanel to act as the gui for board. 到目前为止,我已经创建了一个TableLayoutPanel来充当开发板的gui。 Next is the part I'm stuck at. 接下来就是我要坚持的部分。 I have to display all the squares. 我必须显示所有正方形。 In the project they have supplied a SquareControl class that has the background colour and font of each square but I have no idea how to add these objects to my TableLayoutPanel 在项目中,他们提供了一个SquareControl类,该类具有每个正方形的背景颜色和字体,但是我不知道如何将这些对象添加到TableLayoutPanel中
edit: this is the code for the style of square public SquareControl(Square square, BindingList players) { 编辑:这是正方形的样式代码public SquareControl(Square square,BindingList player){
this.square = square;
this.players = players;
// Set GUI properties of the whole square.
Size = new Size(SQUARE_SIZE, SQUARE_SIZE);
Margin = new Padding(0); // No spacing around the cell. (Default is 3 pixels.)
Dock = DockStyle.Fill;
BorderStyle = BorderStyle.FixedSingle;
BackColor = Color.CornflowerBlue;
LoadImageWhenNeeded();
SetTextColour();
}
U can try following link. 您可以尝试以下链接。 I think It will help u. 我认为这会帮助你。
http://www.dotnetpools.com/Article/ArticleDetiail/?articleId=131 http://www.dotnetpools.com/Article/ArticleDetiail/?articleId=131
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.