I\'m trying to get an UserControl (which has a grid on it) on a Windows Form to resize. The below code is what I have in the Form. The behavior I\'m getting is that the con
You can't directly change the Size.Width
property on a UserControl, because the Size
property is a value type, so changing its width would essentially be overwriting the entire Size
property. Instead, controls in WinForms provide their own Width and Height properties, so this code should work:
grdNameValueProperties.Width = this.Width - 8;
grdNameValueProperties.Height = this.Height - 8;
Having said that, I agree with @recursive's comment that you should probably just use the UserControl's Anchor
property to make it "automatically" resize.