[ACCEPTED]-Vb.net - Setting a controls margin value-margin
Label.Margin returns a
Padding is a structure, it 10 will actually return a copy. You are changing 9 the
Top value of that copy, not of the actual 8 control’s margin. Since that would have 7 no noticeable effect, VB correctly prevents 6 it.
You need to assign a whole new margin. In 5 fact, the
Margin property (or rather, the
Padding class) is 4 arguably broken since it doesn’t allow an 3 easy way to change the individual values.
Unfortunately, we 2 just have to live with it. So to change 1 just the
Top value, we need to write:
Dim old As Padding = LabelAdapter.Margin LabelAdapter.Margin = New Padding(old.Left, 8, old.Right, old.Bottom)
More Related questions