Setting the .Top property removes the Anchor property

I used the Anchor property for some of my controls at design time. but when I change the .Top property of these controls at runtime, it seems like it is messing with the Anchor property and no longer honoring it. what's happening? how to fix?

+3
source share
1 answer

I tried to reproduce the problem you described, but could not accurately match it. The following example, however, may help you solve the problem that I suspect.

(My employer blocks i.imgur.com, the host image for SO. If you have problems viewing screenshots, let me know.)

, .

Screenshot 01

:

groupBox1.Top = 0;

, :

Screenshothot 02

, , - :

Screenshot 03

, , , , . , Top , .

SetBounds(). , . , , , , , .

        int newtop = 0; // the new top bound
groupBox1.SetBounds(
        groupBox1.Left,
        newtop,
        groupBox1.Width,
        groupBox1.Height + groupBox1.Top - newtop);

, - :

Screen shot 04

+2

Source: https://habr.com/ru/post/1762332/


All Articles