I'm trying to create a chessboard using a TableLayoutPanel of 64(8x8) cells, each cell to contain a PictureBox. I also want the chessboard to expand and contract as the user grows or shrinks the form. As you can see, I haven't got very far!
I thought the code below would at least be a start and would display the cells as 64 equal size squares but as you can see, it doesn't.
![Name: TLP_1.PNG
Views: 67
Size: 1.9 KB]()
If, instead, I comment out this code and edit the rows and columns in the designer, setting each row and column to 12.5%, I get this:
![Name: TLP_2.PNG
Views: 56
Size: 2.1 KB]()
which is much closer to what I want but not close enough! Any ideas, please?
I thought the code below would at least be a start and would display the cells as 64 equal size squares but as you can see, it doesn't.
Code:
For i As Integer = 0 To TLP_Chessboard.ColumnCount - 1
Dim tableColumnStyle As New ColumnStyle()
tableColumnStyle.SizeType = SizeType.Percent
tableColumnStyle.Width = CSng(100 / TLP_Chessboard.ColumnCount)
TLP_Chessboard.ColumnStyles.Add(tableColumnStyle)
Next
TLP_Chessboard.RowStyles.Clear()
For i As Integer = 0 To TLP_Chessboard.RowCount - 1
Dim tableRowStyle As New RowStyle()
tableRowStyle.SizeType = SizeType.Percent
tableRowStyle.Height = CSng(100 / TLP_Chessboard.RowCount)
TLP_Chessboard.ColumnStyles.Add(tableRowStyle)
Next
If, instead, I comment out this code and edit the rows and columns in the designer, setting each row and column to 12.5%, I get this:
which is much closer to what I want but not close enough! Any ideas, please?