0

I am currently trying to play around with c#. I want to create a simple GUI containing (as minimal example) three labels. The first two should be aligned from top to buttom and the third one to the right of these two button.

I have this in a panel, like

Label p_LabelX = new Label();
p_LabelX.Text = "I am to the right";

FlowLayoutPanel p_ButtonLayout = new FlowLayoutPanel();
p_ButtonLayout.Width = 200;
Label p_Label1 = new Label();
p_Label1.Text = "I am upper left";

Label p_Label2 = new Label();
p_Label2.Text = "I am lower left";

p_ButtonLayout.Controls.Add(p_Label1);
p_ButtonLayout.Controls.Add(p_Label2);

FlowLayoutPanel p_MainLayout = new FlowLayoutPanel();
p_MainLayout.FlowDirection = FlowDirection.LeftToRight;
p_MainLayout.WrapContents = false;
p_MainLayout.AutoScroll = true;
p_MainLayout.Controls.Add(p_ButtonLayout);
p_MainLayout.Controls.Add(p_LabelX);

this.Controls.Add(p_MainLayout);

With this code, it kind of works, but I have some scrollbars and the mainlayout is not fullscreen within the panel. However, if I skip the AutoScroll line, the scrollbars are gone and the layout seems to be fullscreen, but the right button is not visible.

Any suggestions?

Sarath Subramanian
  • 20,027
  • 11
  • 82
  • 86
curator
  • 175
  • 2
  • 10
  • 1
    This seems to be `System.Windows.Forms`. If you are just starting C#, maybe it's better to start with the current UI implementation, `WPF`. Forms is old and clunky. – nvoigt Dec 03 '14 at 12:19
  • Correct, but I use mono in Linux, such that (afaik) WPF is not an option – curator Dec 03 '14 at 12:26
  • to get the flowlayout to fullscreen try the Dock-property of the FlowLayout and set it to Fill. I've give it a try and it worked here. Maybe you should give the flowlayouts an Borderstyle to see where they are => FlowLayout.BorderStyle = BorderStyle.FixedSingle (for testing) – DJmRek Dec 03 '14 at 12:46
  • 1
    edit: only dock p_mainLayout to Fill. An other option could be a TableLayoutPanel. Happy test'n'learning ;) – DJmRek Dec 03 '14 at 13:07

0 Answers0