سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top