lundi 23 février 2015

C# programmatically position panel to fill one third of the parent form (WinForm)

I have a form with a Panel and a RichTextBox. The Panel is Dock.Top and the RTB is Dock.Bottom. After initialization. I wish to position the panel so it takes up the top 1/3 of the form with the RTB taking up the remaining bottom of the form.


However, the code presented below does not work.



public frmMain()
{
InitializeComponent();
panel1.Top = 0;
panel1.Width = this.Width;
panel1.Height = this.Height / 3;
ConOut.Top = panel1.Height + 10;
ConOut.Width = this.Width;

}


Question 1) What is wrong with the above code so that it does not position the form's controls properly?


Aucun commentaire:

Enregistrer un commentaire