|
-
Mar 17th, 2005, 02:34 PM
#1
Re: Minimize Form1 With MainForm Code
yeah but what I am saying is that you are not using those properties right..
Me.WindowState.Minimized will not evaluate to a boolean like you are trying.. I can tell you are coding without option strict on. I recommend putting it on.
VB Code:
Private MainFormResize(blah blah)
If Me.WindowState = FormWindowState.Minimized Then
Form1.WindowState = FormWindowState.Minimized
Else
Form2.WindowState = FormWindowState.Normal
End If
End Sub
see what i mean
-
Mar 17th, 2005, 02:37 PM
#2
Thread Starter
Fanatic Member
Re: Minimize Form1 With MainForm Code
I'm just getting into this .NET...
Is Option Strict like Option Explicit??
And where does it go?
-
Mar 17th, 2005, 02:45 PM
#3
Re: Minimize Form1 With MainForm Code
 Originally Posted by epixelman
I'm just getting into this .NET...
Is Option Strict like Option Explicit??
And where does it go?
yes and no..
they work together really, but you can have one on and one off vice versa..
your best bet is to put option strict and option explicit both on. This will ensure your code is as clean and correct as possible from a syntax point of view.
Option Strict requires explicit conversions of datatypes..
for example
Dim b As Boolean = "true"
this is setting a string datatype to a boolean (it converts it in the background), but if you had option strict on.. it would not let you do this.. you would have to do
Dim b As Boolean = true
maybe thats a bad example.. but i hope you get the idea..
here is a better example
VB Code:
Dim i As Integer = 100
MessageBox.Show(i)
with option strict, you need to make the integer a string.. because technically, the messagebox.show method needs a string, not an integer
VB Code:
Dim i As Integer = 100
MessageBox.Show(i.ToString)
you can turn on option strict and explict in the options so by default they are always on.. and you always have the option to specify them on or off in a specific class/form/module by coding it at the very top like option explicit in VB6
hope that helps...
-
Mar 17th, 2005, 02:46 PM
#4
Re: Minimize Form1 With MainForm Code
well where are Form1 and Form2 declared? what form are you calling the code from?
-
Mar 17th, 2005, 03:46 PM
#5
Thread Starter
Fanatic Member
Re: Minimize Form1 With MainForm Code
It all comes from the MainForm...
VB Code:
Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
Dim fForm1 As New Form1()
fForm1.Show()
End Sub
Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
If Me.WindowState = FormWindowState.Minimized Then
Form1.WindowState = FormWindowState.Minimized
Else
Form1.WindowState = FormWindowState.Normal
End If
End Sub
I am using SharpDevelop for my IDE. I do not have an option to set the "Option Explicit" and "Option Strict" on.
Where in raw code does it go?
Above the namespace section?
Thanks
-
Mar 17th, 2005, 03:52 PM
#6
Re: Minimize Form1 With MainForm Code
yes at the very top of everything... same place you would put option explicit
Option Explicit On
Option Strict On
your problem is that the scope of your form variables are limited to the subs you create them in... move the declarations for the forms to the module level...
VB Code:
Private fForm1 as Form1
Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
fForm1 = New Form1()
fForm1.Show()
End Sub
Private Sub MainFormResize(sender As System.Object, e As System.EventArgs)
If Me.WindowState = FormWindowState.Minimized Then
Form1.WindowState = FormWindowState.Minimized
Else
Form1.WindowState = FormWindowState.Normal
End If
End Sub
-
Mar 17th, 2005, 03:55 PM
#7
Thread Starter
Fanatic Member
Re: Minimize Form1 With MainForm Code
Module Level???
Where and how would I call them?
-
Mar 17th, 2005, 02:44 PM
#8
Thread Starter
Fanatic Member
Re: Minimize Form1 With MainForm Code
 Originally Posted by kleinma
VB Code:
Private MainFormResize(blah blah)
If Me.WindowState = FormWindowState.Minimized Then
Form1.WindowState = FormWindowState.Minimized
Else
Form2.WindowState = FormWindowState.Normal
End If
End Sub
Does this minimize both forms when I minimize the Main Form??
I am getting an error on line... (ref to non-standard member requires obj ref)
Private MainFormResize(blah blah)
If Me.WindowState = FormWindowState.Minimized Then
------>> Form1.WindowState = FormWindowState.Minimized
Else
------>> Form1.WindowState = FormWindowState.Normal
End If
End Sub
I'm only trying to minimize Form1 (toolbox) when I minimize MainForm (that is the name)
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|