I am trying to have a TextBox that spans the entire height and width of its form. I initially set the width and height to auto, but that causes it to grow as more text is entered where I would prefer it to always be 100% of the width and height.
I read about the dock and anchor property here C# - Stretching a textbox to fit the containing window and based off the code there and at MSDN I would like to do something like
TextBox foo = new TextBox();
foo.Dock = DockStyle.Fill;
foo.Anchor = AnchorStyles.Left;
TextBox.Anchor apply to the WinForms TextBox not WPF's. For WPF you can achieve the same behavior with
HorizontalAlignment properties as indicated below:
var foo = new TextBox(); foo.VerticalAlignment = VerticalAlignment.Stretch; foo.HorizontalAlignment = HorizontalAlignment.Stretch;