如何编辑windows生成的设计器代码 [英] How to edit windows generated designer code

查看:146
本文介绍了如何编辑windows生成的设计器代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体但由于一些错误我无法看到UI。现在我想修改Windows窗体设计器生成的代码但没有任何工作。即使我改变按钮的大小,大小仍然是相同。请帮助我.TIA



  .btnReset .Location =  new  System.Drawing.Point( 330  15 ); 
.btnReset.Name = btnReset ;
this .btnReset.Size = new System.Drawing.Size( 0 23 );
this .btnReset.TabIndex = 23 ;
.btnReset.Text = 重置;
.btnReset.UseVisualStyleBackColor = true ;
this .btnReset.Click + = new System.EventHandler( .btnReset_Click);





这里我将按钮的宽度设置为0,但宽度不会改变。



我尝试了什么:



我尝试在设计师代码中添加一些按钮和组合框并改变了现有按钮的大小但没有任何效果。

解决方案

好吧,按钮显然没有将'AutoSize属性设置为'true(默认为' false),或其'MinimumSize属性集(默认值为0,0)。



在Designer.cs文件中将按钮'宽度设置为#0不会导致编译时或运行时错误:它只会隐藏按钮。



然后,将'宽度设置为#0以隐藏控件不会感觉:通过将其可见属性设置为错误来隐藏控件。



所以还有其他事情发生,你需要在这里分享的重要信息是尝试打开For时会收到哪些错误消息在'设计师视图中'。



当我搞砸了一些我无法访问设计师视图时使用的策略是:



首先,请务必复制破损的项目,并保存以备将来重复使用。



a 。打开另一个Visual Studio实例,创建一个新项目。



b。重新创建UI,为NameSpace和Forms,UserControls等使用相同的名称。



c。



c.1。从损坏的项目复制并粘贴代码(类,表单代码)到新的项目等效代码隐藏。



c.2。在我保存重要代码之后,我不想从原始项目中丢失,然后返回并开始一次一个地从Designer.cs文件中删除各种UI元素,直到找出已损坏的内容。



但是,如果您能够弄清楚当您无法在设计中打开表单或UserControl或Component时获得的错误消息,则可以避免这种脏业务图。

I have a windows form but i am unable to see the UI because of some errors.Now i want to modify the Windows Form Designer generated code but nothing is working.Even though i change the size of the button the size remains the same.Please help me with this.TIA

this.btnReset.Location = new System.Drawing.Point(330, 15);
         this.btnReset.Name = "btnReset";
         this.btnReset.Size = new System.Drawing.Size(0, 23);
         this.btnReset.TabIndex = 23;
         this.btnReset.Text = "Reset";
         this.btnReset.UseVisualStyleBackColor = true;
         this.btnReset.Click += new System.EventHandler(this.btnReset_Click);



Here i set the width of the button to 0 but the width is not changed.

What I have tried:

I have tried adding some buttons and groupbox to the designer code and changed the size of the existing buttons but nothing worked.

解决方案

Well the 'Button evidently does not have its 'AutoSize Property set to 'true (the default is 'false), or its 'MinimumSize Property set (the default is 0,0).

Setting a Button 'Width to #0 in the Designer.cs file will not cause a compile-time, or run-time, error: it will just hide the Button.

And, setting 'Width to #0 to hide a Control makes no "sense:" hide a Control by setting its 'Visible Property to 'False.

So something else is going on, and the important information you need to share here is what error messages you get when try to open the Form in 'Designer View.'

A strategy I have used when something is so screwed-up that I can't access the designer view is:

First, always make a copy of the broken Project, and save it for possible future re-use.

a. open another instance of Visual Studio, create a new Project.

b. re-create the UI, use the same Names for NameSpace and Forms, UserControls, etc.

c. either

c.1. copy-and-paste code (Classes, Form Code) from the broken Project to the new Project equivalent code-behind.

c.2. after I have saved important code I don't want to lose from the original project, then go back and start deleting the various UI elements from the Designer.cs file one-at-a-time until you isolate what's broken.

However, this "dirty business" might be avoided if you can figure out what the error messages you get when you can't open the Form or UserControl, or Component, in design view.


这篇关于如何编辑windows生成的设计器代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆