Josh M
Josh M

Reputation: 173

How do I set dock property of a datagridview properly?

In a datagridview when I set:

Which will expand or shrink the datagridview based on size of the form, and covers the whole form. But what of I have controls on the right side on the form? I don't want to overlap my linkbuttons with my gridview. I know there's a "Margin" and "Default Cell Style" property with padding values (specifically using "right padding" to try and reduce width from the right of the right edge of the form). So I tried messing with that, didn't do anything I want. Or was I working with the right properties, just not setting them right?

Upvotes: 0

Views: 4683

Answers (2)

niaomingjian
niaomingjian

Reputation: 3742

1.Use a panel to split the form into two sections.
The right section is placed with DataGridView, and the left section is placed with a panel which is used to contain your other controls, like linkbuttons.
2.Set the Dock property of this panel to Right.
3.Set the Dock property of this DataGridView to Fill.

Upvotes: 0

Abdul Saleem
Abdul Saleem

Reputation: 10622

Put those controls you want on the right in a Panel.

Set the DockStyle of that panel as DockStyle.Right.

If you can't see the right edge of the Datagrid means, you have to bring the Datagrid to front by selecting it, right click and choose bringToFront.

Or Send the Panel to back.

Upvotes: 1

Related Questions