0

Question

How can I stop my datagridview from moving underneath the panel when the window is resized?

Example

enter image description here

What I have tried? And what I would like.

  • I have tried to dock the datagridview to the top on the window, but it just docks under the panel.

  • I have tried docking both to the top and docking one to the top and the other to the bottom, however they both just take half the screen up.

What I would like is if the datagridview docked to the bottom of the panel.

1 Answer 1

1

You have to modify the Anchor property on your controls. Based on what you've provided, the DataGridView control is probably anchored Bottom, Right, and you should anchor it Top, Left to match what the panel control's anchor is.

Also, if you do want the grid to be anchored to the bottom, right, you can set the MinimumSize property of your form accordingly so that it can never be resized such that the controls "collide".

It's not possible without third-party controls to dock one control to another control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.