c# Relative position of elements in Windows Form
I try to create simple app with 2 columns using SpliterContainer and
control panel with buttons. And I would like that on every screen it will
look good. That's why I decided to use relative position of elements.
I read documentation and different forums, but I get something strange.
Second column of splitter doesn't appear at all.
Please, can you help me find the reason of that problem?
private void Form1_Load(object sender, EventArgs e)
{
WindowState = FormWindowState.Maximized;
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
int screenHeight = Screen.PrimaryScreen.Bounds.Height;
//set form size
this.Size = new Size(screenWidth, screenHeight);
//set button panel size
const double percentOfHeightPanel = 0.05;
int heightOfPanelButton = Convert.ToInt32(screenHeight *
percentOfHeightPanel);
this.panel_button.Size = new System.Drawing.Size(screenWidth,
heightOfPanelButton);
this.panel_button.Location = new Point(0, 0);
//set splitContainer size
int widthOfContainer = Convert.ToInt32(0.5 * screenWidth);
int heightOfContainers = Convert.ToInt32(screenHeight * (0.95));
splitContainer1.Panel1.MinimumSize = new
Size(widthOfContainer, heightOfContainers);
splitContainer1.Panel2.MinimumSize = new
Size(widthOfContainer, heightOfContainers);
splitContainer1.Location = new Point(0, heightOfPanelButton);
//this.splitContainer1.Panel2MinSize = screenWidth -
widthOfContainer;
//set textBox size
this.textBox1.Multiline = true;
this.textBox1.Location = new Point(0, heightOfPanelButton);
this.textBox1.MinimumSize = new
System.Drawing.Size(widthOfContainer, heightOfContainers);
this.textBox2.Multiline = true;
this.textBox2.Location = new Point(widthOfContainer,
heightOfPanelButton);
this.textBox1.MinimumSize = new
System.Drawing.Size(widthOfContainer, heightOfContainers);
}
No comments:
Post a Comment