且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我遇到关于tabcontrol的错误

更新时间:2023-12-06 17:15:10

您正在显示不相关的代码.不,现在不显示任何代码,您不是很了解自己的代码的功能.您的样本是不相关的,因为System.Windows.Forms中存在异常:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.updatetabselection.aspx [ ^ ].

而且,您没有在堆栈跟踪中显示任何有关此调用的代码.您会发现,例外是最容易解决的问题之一.在调试器下运行它.首先,找到对上面显示的方法的调用,并在此行上放置一个断点.尝试运行.调用之前,请先查看所涉及的成员和变量.其中至少有一个为空,但不应假定为空.调用前检查调试器下的所有相关值,并找出错误.将这种方法应用于其他情况.修复错误:确保有问题的引用变量或成员使用非空引用进行初始化(调用了构造函数,或者将您的引用分配给了一些已初始化的变量),或者在适当的情况下执行了条件语句:检查变量或有问题的成员为null,如果为null,则不要在使用该成员的位置进行操作.

—SA
You are showing unrelated code. No, don''t show any code right now, you don''t really understand what your own code does. You sample is unrelated, because the exception is in System.Windows.Forms:
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.updatetabselection.aspx[^].

And you did not show any code around this call shown in your stack trace. You see, you exception is one of the easiest to fix. Run it under debugger. To start with, locate your call to the method shown above and put a breakpoint on this line. Try to run. Before the call, look at the members and variables involved. At least one of them is null but is not supposed to be null. Inspect all relevant value under debugger before a call and find out the bug. Apply this approach to other cases. Fix the bug: either make sure the problematic reference variable or member is initialized with a non-null reference (constructor called or your reference is assigned to some already initialized variable), or, if appropriate, make a conditional statement: check a variable or a member in question for null and don''t the operation where it is used if it is null.

—SA