惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
F
Fortinet All Blogs
The Register - Security
The Register - Security
雷峰网
雷峰网
博客园 - 【当耐特】
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
S
Schneier on Security
Latest news
Latest news
S
Securelist
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
NISL@THU
NISL@THU
Cyberwarzone
Cyberwarzone
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
Spread Privacy
Spread Privacy
酷 壳 – CoolShell
酷 壳 – CoolShell
Security Latest
Security Latest
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
SecWiki News
SecWiki News
N
News and Events Feed by Topic
T
Threatpost
The GitHub Blog
The GitHub Blog
博客园_首页
F
Full Disclosure
爱范儿
爱范儿
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
Last Week in AI
Last Week in AI
月光博客
月光博客
C
Check Point Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
博客园 - 司徒正美

博客园 - 田了你

[ZF]开心一下 [转]Java jdbc数据库连接池总结! 一台机器部署N个server步骤 [转]软件开发者面试百问 09年的第一篇日志比已往的时候来得更早一些 - 田了你 - 博客园 [转]关于锚点 - 田了你 - 博客园 从今天开始每天写一篇日志咯 Telerik RadGrid 翻页问题解决 - 田了你 果然是本命年 javascript注册事件的四种方式 - 田了你 - 博客园 Tomcat5.x的项目部署 又被老板欺骗了 2007.2.1 -----2007.4.1安排计划 关于NTKO_office的操作(从数据库中提取数据,写入到NTKO_office_Word中) [转]JS代码格式化工具(附源代码) 层的拖动 获得控件在页面上的绝对位置的方法 解决SQL2000乱码问题 ref与out
.net的优点变缺点(郁闷了一天)
田了你 · 2007-02-09 · via 博客园 - 田了你

.net的优点变缺点(郁闷了一天)

今天在改写‘试题编辑器’时,
发现我在InitializeComponent()方法中写的代码消失了
(我在InitializeComponent中进行了PanelEdit = new PanelClass)
而我的PanelClass为自定义的panel.
编译的时候出现了PanelEdit 未对象事例的错误。
一看InitializeComponent中自己写的代码已经消失了
尴尬的花了一个小时才找到原因:.net自作聪明的根据form元素帮你重新生成代码,把我写的代码删除掉了。
解决方案:(1)适合于:(webForm)。定义为一个方法,在OnInit里进行调用
              (2 )适合于(WinForm):定义为一个方法,构造函数里进行调用。且在InitializeComponent()方法前进行调用。
eg:
  private void getPanleEidt()
  {
   this.PanelEdit = new WordInDOTNET.PanelClass();
   // PanelEdit
   this.PanelEdit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));
   this.PanelEdit.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
   this.PanelEdit.diffNumber = 0;
   this.PanelEdit.Disp = null;
   this.PanelEdit.Location = new System.Drawing.Point(136, 80);
   this.PanelEdit.Name = "PanelEdit";
   this.PanelEdit.Size = new System.Drawing.Size(712, 240);
   this.PanelEdit.TabIndex = 26;
   this.PanelEdit.testType = null;
   this.Controls.Add(this.PanelEdit);
  }
//构造函数
  public frmMain()
  {
   //
   // Required for Windows Form Designer support
   //
   //初始PanleEidt
   this.getPanleEidt();
   InitializeComponent();
  }