3

Here's what I did:

  1. Place a TextBox control
  2. Set its Multiline property to True, and its Dock property to Fill
  3. Place a Button control (also works with a ToolStrip, which is docked at the top by default, and many other controls)
  4. Set its Dock property to Top

Here's the problem I'm having:

The button is overlapping the text field.

Shouldn't the top of the text field be at the bottom of the button? Why is the button overlapping it?

flarn2006
  • 1,787
  • 15
  • 37

1 Answers1

4

You are using the wrong sequence, when you place your TextBox first and set its Dock Property to Fill it will take up the Form's complete client area, then when you place your Button it overlays your TextBox. Try adding the Button first setting its Dock Property to Top, then add your TextBox setting its Dock Property to Fill. It should then work as expected.


On further investigation it looks like it has to do with the z-order, if you right click your button and select send to back it should cause the textbox to correct itself.

Mark Hall
  • 53,938
  • 9
  • 94
  • 111
  • Okay, but how would I change that once I've already placed the controls without having to delete them? It's just that if later I decide to add a new docked control, I don't want to have to delete it and make it again. Is there any quicker way to do that, barring editing the .Designer.cs? – flarn2006 Oct 01 '13 at 02:42
  • It looks like it has to do with the z-order, if you right click your button and select send to back it should cause the textbox to correct itself. – Mark Hall Oct 01 '13 at 02:58