Hi,
I want to make a really simple form with C# and windows forms, which is
trivial with Java, but I'm unable to reproduce it with .NET. I can't
believe it's impossible.
I want a simple window with a textbox and a listbox below it. I don't
want to use fixed coordinates and sizes, since that's what layout
managers are for. I want the textbox and the listbox resize themselves
automatically if I resize the window. The textbox should resize only
horizontally (since the default height is okay) and the listbox should
resize both horizontally and vertically (it should fill all the
available space in the window below the textbox).
I used FlowLayoutPanel (I don't want to create a custom layout manager,
since this kind of form is really simpe) and added the two controls to
it. The controls appear, but they do not fill the window. What can the
problem be?
public class Myapp : Form
{
ListBox box = new ListBox();
TextBox text = new TextBox();
public Myapp()
{
FlowLayoutPanel panel = new FlowLayoutPanel();
panel.FlowDirection = FlowDirection.TopDown;
panel.Dock = DockStyle.Fill;
panel.Controls.Add(text);
panel.Controls.Add(box);
Controls.Add(panel);
StartPosition = FormStartPosition.CenterScreen;
}
...