The designer automatically changes shape when certain properties are set.

I ran into a problem when the WinForms form is automatically updated every time the designer opens.

This only happens with a specific setting, however it can be easily reproduced using the following steps ...

  • Create a new project in visual studio
  • The default form size is 300 x 300, but all you did was take a note
  • Set the property FormBorderStyletoFixedSingle
  • Set the property ShowIcontofalse
  • Set the property ControlBoxtofalse
  • Save changes
  • Close constructor
  • Reopen the constructor, and you will notice that the shape has been reduced by 4 pixels (width and height).

The problem with this is that when this happens, it does not resize any of the controls (i.e. those that are set using anchors), so this means that I get controls that overlap the edge of the form, and everything has to be manually adjusted every time I open the constructor, which is a pain.

So the question is: why is this happening, and what can I do to prevent this from happening?


I am currently using Visual Studio 2012 Professional, and John Willem confirmed through comments that this problem is also present in Visual Studio 2010 Professional.

+4
source share
1 answer

, ​​ VS. ShowIcon, , False. Form, :

       FormBorderStyle borderStyle = FormBorderStyle;
       if (!ShowIcon &&
           (borderStyle == FormBorderStyle.Sizable ||
            borderStyle == FormBorderStyle.Fixed3D ||
            borderStyle == FormBorderStyle.FixedSingle))
       {
           cp.ExStyle |= NativeMethods.WS_EX_DLGMODALFRAME;
       }

, ShowIcon False, WS_BORDER, . Windows, . , , , - Windows 98.

, Size , Winforms ClientSize. , ShowIcon False, , .

connect.microsoft.com, , Microsoft , , , , . , , ShowIcon False "", . :

    public Form1() {
        InitializeComponent();
        this.ShowIcon = false;
    }
+7

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


All Articles