Perhaps do it this way:
Make a standard forms application and fill in this code:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public const int MaxLen = 10;
public const int ButtonSide = 40;
// Declare empty 2D button array of 100 buttons
private Button[,] MyButtons = new Button[MaxLen, MaxLen];
public Form1()
{
InitializeComponent();
this.Size = new Size(450, 450); //increase size of form a bit to see all the buttons
for (int row = 0; row < MaxLen; row++)
{
for (int col = 0; col < MaxLen; col++)
{
MyButtons[row, col] = new Button(); //make a button in the array
MyButtons[row, col].Height = ButtonSide;
MyButtons[row, col].Width = ButtonSide;
MyButtons[row, col].Location = new Point(row * ButtonSide + 10, col * ButtonSide + 10);
MyButtons[row, col].Name = "b" + row.ToString() + col.ToString();
int ButtonNumber = col * MaxLen + row + 2;
MyButtons[row, col].Text = ButtonNumber.ToString(); //put text on button
this.Controls.Add(MyButtons[row, col]); // add button to form
}
}
}
}
}
Now all you have to do is to hide the buttons with a text that is not a prime number. Hope it helps.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661