Form_Load第二次激发 - VB.NET [英] Form_Load fires second - VB.NET

查看:187
本文介绍了Form_Load第二次激发 - VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象需要在其他任何事情发生之前添加到List中,所以我将List1.Add放在Form_Load中。问题是其他事情首先发生,当然崩溃,因为列表首先是空的。我不能在函数或子函数之外的表单类顶部执行List1.Add。



我怎样才能保证在其他任何事情之前绝对会发生某些事情如果不是在Form_Load中?

I have an object that I need to add to a List before anything else happens, so I put List1.Add in Form_Load. The problem is other things are happening first, and of course crashing since the list is empty first. And I can't do List1.Add at the top of the form class outside of a function or sub.

How can I guarantee something will happen absolutely before anything else if not in Form_Load?

推荐答案

也许使用类构造函数。


这篇关于Form_Load第二次激发 - VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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