Don't use the object: ActiveForm unless you check it for null each time you do.
This object is in my opinion flawed and not all that useful since it becomes
null when the form loses focus. I am posting this warning lest you too fall
into the trap of using the ActiveForm.refresh() method instead of the
tnis.refresh(); method.
They are not the same and you may or maynot find your program crashing
because you did not first check each time you call the refresh method
associated with the object again try not to use ActiveForm object and instead
use the this object of the form or the actual form itself.

I think this is a bad design for ActiveForm object. Bottom line is do not
use it unless you are absolutely forced to. Instead use the this.object


Here is the original error message I ultimately solved:
System.NullReferenceException: Object reference not set to an instance of an
object

RE: Don't use the object: ActiveForm unless you check it for null each by ROB

ROB
Thu May 19 18:00:06 CDT 2005

oops: tnis.refresh(); was a mistake
this.refresh(); was what was intended sorry! (:<)=

"ROB" wrote:

> Don't use the object: ActiveForm unless you check it for null each time you do.
> This object is in my opinion flawed and not all that useful since it becomes
> null when the form loses focus. I am posting this warning lest you too fall
> into the trap of using the ActiveForm.refresh() method instead of the
> tnis.refresh(); method.
> They are not the same and you may or maynot find your program crashing
> because you did not first check each time you call the refresh method
> associated with the object again try not to use ActiveForm object and instead
> use the this object of the form or the actual form itself.
>
> I think this is a bad design for ActiveForm object. Bottom line is do not
> use it unless you are absolutely forced to. Instead use the this.object
>
>
> Here is the original error message I ultimately solved:
> System.NullReferenceException: Object reference not set to an instance of an
> object
>

Re: Don't use the object: ActiveForm unless you check it for null each by Bruce

Bruce
Thu May 19 18:22:13 CDT 2005

Yes, you should always check ActiveForm before you use it. Here is an
example from my code:

Form activeForm = Form.ActiveForm;
Cursor oldCursor = Cursors.Default;
if (activeForm != null)
{
oldCursor = activeForm.Cursor;
activeForm.Cursor = Cursors.WaitCursor;
}
try
{
... do some stuff
}
finally
{
if (activeForm != null)
{
activeForm.Cursor = oldCursor;
}
}