Form size

  • Thread starter Thread starter Hugh
  • Start date Start date
H

Hugh

Hi,

I used following sentex to change form width:

MainForm.ActiveForm.width = 200

However, a error was generated: An unhandled exception of
type 'System.NullReferenceException' occurred. I am
confused. The same command works for other applications.
Any idea.

Thanks.

Hugh
 
Hugh said:
I used following sentex to change form width:

MainForm.ActiveForm.width = 200

However, a error was generated: An unhandled exception of
type 'System.NullReferenceException' occurred. I am
confused. The same command works for other applications.
Any idea.

The syntax can be misleading. ActiveForm is a shared property, so the line
is actually

System.Windows.Forms.Form.ActiveForm.Width = 200

The error occurs when there is no active Form and ActiveForm returns
Nothing.
 
Hello, Hugh:

Try this:

'\\\
if not mainform.activeform is nothing then
mainform.activeform.width=200
else
msgbox "This application hasn't any active form."
end if
'///

Regards.


"Hugh" <[email protected]> escribió en el mensaje | Hi,
|
| I used following sentex to change form width:
|
| MainForm.ActiveForm.width = 200
|
| However, a error was generated: An unhandled exception of
| type 'System.NullReferenceException' occurred. I am
| confused. The same command works for other applications.
| Any idea.
|
| Thanks.
|
| Hugh
 
Hi,

I understand your point. However, there is active form
and I still receive the error message. If I started form
code window, it is undertandable that the error. How to
change a form's size programatically?

Thanks and Merry Christmas.

Hugh
-----Original Message-----
Hello, Hugh:

Try this:

'\\\
if not mainform.activeform is nothing then
mainform.activeform.width=200
else
msgbox "This application hasn't any active form."
end if
'///

Regards.


"Hugh" <[email protected]> escribió en
el mensaje news:[email protected]...
 
* "Hugh said:
I used following sentex to change form width:

MainForm.ActiveForm.width = 200

However, a error was generated: An unhandled exception of
type 'System.NullReferenceException' occurred. I am
confused. The same command works for other applications.
Any idea.

Maybe there is no form active? Where do you use the code?

\\\
If MainForm.ActiveForm Is Nothing Then
MsgBox("No form active!")
Else
MainForm.ActiveForm.Width = 200
End If
///
 
Hi,

You mean you still receive the error with the code I posted?
That means that the variable MainForm has not been initialized.

If you mean that there is an active form but MainForm.ActiveForm still is Nothing, then maybe the form has not completed its initialization when you call this method.

If this doesn't help, please tell us what event are you calling MainForm.ActiveForm from, and maybe some more information about the circumstances.

Merry Christmas.


"Hugh" <[email protected]> escribió en el mensaje Hi,

I understand your point. However, there is active form
and I still receive the error message. If I started form
code window, it is undertandable that the error. How to
change a form's size programatically?

Thanks and Merry Christmas.

Hugh
-----Original Message-----
Hello, Hugh:

Try this:

'\\\
if not mainform.activeform is nothing then
mainform.activeform.width=200
else
msgbox "This application hasn't any active form."
end if
'///

Regards.


"Hugh" <[email protected]> escribió en
el mensaje news:[email protected]...
 
Back
Top