Cannot modify expression because it is not a variable

后端 未结 5 778
情书的邮戳
情书的邮戳 2020-12-20 19:34

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

5条回答
  •  隐瞒了意图╮
    2020-12-20 20:07

    For the first portion -

    First off, I'd recommend using the Anchor property on UserControl instead of trying to size this yourself. It works very simply, and very reliably, for handling window resizing.

    If you want to do this, you should probably look at chaining off this.ClientSize instead of this.Height and this.Width. You're probably setting your control too large, and that's unachoring the panel or other thing you're sitting on, which causes all sorts of issues.

    The second part is due to the fact that gridNameValue Properties.Size.Width is a member of a struct.

    When you call gridNameValueProperties.Size, you're returning a Size struct, then trying to set the Width on the returned struct (not the original). This is why you need to set the entire Size valuetype in one shot. Creating a new Size() and setting it to gridNameValueProperties.Size is the only way to make that work.

提交回复
热议问题