- #1
TheDemx27
Gold Member
- 169
- 13
I have wrote a program to resize buttons and such on my windows form. It doesn't seem to be doing much of anything. When I run the program it just shows me the form and it doesn't react to my resizing of it.
Code:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private bool playerTurn = false;
private Image x = Properties.Resources.Image1;
private Image y = Properties.Resources.Image2;
private void Resize()
{
int defaultWidth = (this.ClientRectangle.Width - radioButton1.Width) / 3;
button1.Width = button2.Width =
button3.Width = button4.Width =
button5.Width = button6.Width =
button7.Width = button8.Width =
button9.Width = defaultWidth;
int defaultHeight = (this.ClientRectangle.Height - menuStrip1.Height) / 3;
button1.Height = button2.Height =
button3.Height = button4.Height =
button5.Height = button6.Height =
button7.Height = button8.Height =
button9.Height = defaultHeight;
int secondColumn = button1.Width;
int thirdColumn = 2 * button1.Width;
button1.Left = button4.Left = button7.Left = 0;
button2.Left = button5.Left = button8.Left = secondColumn;
button3.Left = button6.Left = button9.Left = thirdColumn;
int firstRow = menuStrip1.Height;
int secondRow = menuStrip1.Height + button1.Height;
int thirdRow = menuStrip1.Height + 2 * button1.Height;
button1.Top = button2.Top = button3.Top = firstRow;
button4.Top = button5.Top = button6.Top = secondRow;
button7.Top = button8.Top = button9.Top = thirdRow;
radioButton1.Left = button3.Left + button3.Width + 5;
radioButton2.Left = radioButton1.Left;
radioButton1.Top = button3.Top;
radioButton2.Top = radioButton1.Top + radioButton1.Height + 10;
button10.Left = button11.Left = radioButton1.Left;
button10.Top = radioButton2.Top + radioButton2.Height + 10;
button11.Top = button10.Top + button10.Height + 10;
}
public Form1()
{
InitializeComponent();
Resize();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}