I have also been writing a Sudoku solving program but I have been using C# .NET.

When I clean up the objects that do the solve (it will solve a complete puzzle of mediumn complexity. I need to add other algorhythyms to solve for the harder level puzzles). I will post them on this thread for review/comments.

However in the mean time I need some help with my GUI object for this whole project.

I am pretty new to .NET programming and was hoping someone could tell me why this is not working right.

Any help you guys could give me would be greatly appreciated!!!

Source Notes: I am creating 9 panels which divide the main 9x9 grid into 9 smaller 3x3 grids (just like the Sudoku Puzzle). I am hoping by creating the GUI this way, it will be easier to implement the object connections to the actual cell data that will connected to each grid button.

I am also interested in making the buttons size dynamically depending on how big the form is. If anyone can point me in the right direction to do that I will try to implement that feature as well.

OUTPUT (Note only 1 panel paints the buttons, they all paint the same way and I can't for the life of me figure out why the other 8 panels are missing the buttons!!):



SOURCE:

Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace SudokuGridFormA
{
	public class SudokuGridForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Panel [,] panel = new Panel[3,3];
		private System.Windows.Forms.Button [,] GridBtn = new Button[9,9];
		private int TABINDEXNUM = 0;
		

		public SudokuGridForm()
		{
			InitializeComponent();
		}

		private int TABINDEX()
		{
			TABINDEXNUM++;
			return(TABINDEXNUM);
		}

		private void AddPanel(int panelNumX, int panelNumY, int x1, int x2, int y1, int y2)
		{
			this.panel[panelNumX,panelNumY].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

			for(int y=y1; y<=y2; y++)
				for(int x=x1; x<=x2; x++)
				{
					this.GridBtn[x,y] = new System.Windows.Forms.Button();
					this.panel[panelNumX,panelNumY].Controls.Add(this.GridBtn[x,y]);
				}

			this.panel[panelNumX,panelNumY].Location = new System.Drawing.Point(24+(panelNumX*96),32+(panelNumY*96));
			this.panel[panelNumX,panelNumY].Name = "panel" + panelNumX.ToString()+panelNumY.ToString();
			this.panel[panelNumX,panelNumY].Size = new System.Drawing.Size(96, 96);
			this.panel[panelNumX,panelNumY].TabIndex = TABINDEX();

			for(int y=y1; y<=y2; y++)
				for(int x=x1; x<=x2; x++)
				{
					this.GridBtn[x,y].Location = new System.Drawing.Point(0+(x*32), 0+(y*32));
					string BtnName = "GridBtn"+panelNumX.ToString()+panelNumY.ToString()+x.ToString()+y.ToString();
					this.GridBtn[x,y].Name = BtnName;
					this.GridBtn[x,y].Size = new System.Drawing.Size(32, 32);
					this.GridBtn[x,y].Text = panelNumX.ToString()+panelNumY.ToString()+x.ToString()+y.ToString();
					this.GridBtn[x,y].TabIndex = TABINDEX();
				}
		}

		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
				{
					this.panel[x,y] = new System.Windows.Forms.Panel();
					this.panel[x,y].SuspendLayout();
				}

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
				this.groupBox1.Controls.Add(this.panel[x,y]);
			
			this.groupBox1.Location = new System.Drawing.Point(16, 24);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(336, 344);
			this.groupBox1.TabIndex = TABINDEX();
			this.groupBox1.TabStop = false;

			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
					AddPanel(x,y,x*3,2+(x*3),y*3,2+(y*3));			
			
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(368, 382);
			this.Controls.Add(this.groupBox1);
			this.Name = "SudokuGridForm";
			this.Text = "SudokuGridForm";
			this.groupBox1.ResumeLayout(false);
			for(int y = 0; y<3; y++)
				for(int x = 0; x<3; x++)
					this.panel[x,y].ResumeLayout(false);
			this.ResumeLayout(false);
		}
	}
}