Visual Studio中的表单设计器会覆盖我的代码

时间:2015-05-26 12:38:45

标签: c# visual-studio-2013

我的工具条太窄了。我进入Form1.Designer.cs并尝试修复它。我找到了:

this.toolStrip1.Size = new System.Drawing.Size(284, 25);

并将25更改为55.当我再次运行visual studio时,它会告诉我代码已更改,并询问我是否要运行它。但似乎图形设计工具以某种方式覆盖了我的更改,因为当我再次运行应用程序时,with保持不变。

我在Form1.Designer.cs中找到了这段有趣的代码

#region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {

我可以做些什么来使图形设计工具无法更改我的代码吗?

是的,我也尝试通过尝试更改图形工具本身的布局来尝试最明显的解决方案,但我无法重新调整工具条的大小

1 个答案:

答案 0 :(得分:2)

AutoSize属性设置为false

this.toolStrip1.AutoSize = false;
this.toolStrip1.Size = new System.Drawing.Size(284, 55);
相关问题