473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Form size

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
Nov 20 '05 #1
7 1891
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" <an*******@discussions.microsoft.com> escribió en el mensaje news:01****************************@phx.gbl...
| 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
Nov 20 '05 #2
"Hugh" <an*******@discussions.microsoft.com> schrieb

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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
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" <an*******@discussions.microsoft.com> escribió en el mensaje news:01****************************@phx.gbl...| 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
.

Nov 20 '05 #4
* "Hugh" <an*******@discussions.microsoft.com> scripsit:
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
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
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" <an*******@discussions.microsoft.com> escribió en el mensaje news:01****************************@phx.gbl...
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" <an*******@discussions.microsoft.com> escribió en el mensaje news:01****************************@phx.gbl...| 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


Nov 20 '05 #6
Cor
Hi Hugh,
How to change a form's size programatically?


Strange no simple answer,

me.width=200

Merry Chrismass

Cor
Nov 20 '05 #7
"Cor" <no*@non.com> schrieb
How to change a form's size programatically?
Strange no simple answer,

me.width=200


What if me is not the active Form?
Merry Chrismass


Same to you! :-) (apart from the "s" ;)
--
Armin

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
1
by: Sithlord999 | last post by:
Hello. I'm working on an email form on Dreamweaver and I'm looking for a PHP code to make it work. The form with some required fields would send the submitted information and two image attachments...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
2
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
2
by: punitshrivastava | last post by:
Hi to All. I am Punit Shrivastava.I am working in Asp.As i am new in this technology please help me. I want to create enquiry form in Asp. For this i code like this: <form name="enquiry"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.