简体   繁体   中英

C# says this.Controls is null, why?

Earlier my code was running nicely.. then I edited some .. did not touch the designer code.

alt text http://img718.imageshack.us/img718/3759/errorstack.jpg

Why this error is being shown?

如果这是Windows窗体-您是否从窗体的构造函数中删除了InitializeComponent()行?

Maybe its the label is Null and that's causing the trouble. I'm not that experienced with C# but it could be the case that Controls doesn't except a Null-Pointer.

Looks like, at this point in code label1 is not yet initialized. Whic event handler are you coding this in ? Make sure controls are initialized before using them. Make sure you are using the controls after InitComplete event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM