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.