|
-
Mar 29th, 2002, 07:53 PM
#1
Thread Starter
Hyperactive Member
Nasty objects in C#
Code:
frmNickname nick = new frmNickname();
nick.Show();
Isn't this stupid? This is since J++.
Is there no way to show the form object only?
Do I always have to create a new instance of the object?
The show property isn't supported unless I do this.
This could bring you in troubles:
Let's say you have a MainForm and this form shows a
new one (maybe a dialog). Perhaps you want to disable
the MainForm so that only the new form is enabled.
What would you do when you want to re-enable the first
form?
The "enabled" property is not show unless you create a
new instance of the base MainForm.
But if you do this, a new instance will first be created and
then enabled but not the first MainForm.
You can try to write a function:
Code:
public static bool Enable(bool Value)
{
// ... Code for enabling or disabling the form comes here
}
This code will need the "this" object, but this is not allowed
in static methods.
Crazy! Isn't it?
Any ideas how to prevent this?
thx!
-
Mar 29th, 2002, 10:47 PM
#2
Frenzied Member
here is what you do guy
you make a class called
CMyForms
and you instantiate objects in this class
and you can use one object of this class through out your forms that contains your other forms
-
Apr 2nd, 2002, 06:17 PM
#3
Will this help in the case of dialogs or do I not understand what you are saying?
Code:
frmNickname nick = new frmNickname();
nick.ShowDialog();
-
Apr 2nd, 2002, 07:44 PM
#4
Thread Starter
Hyperactive Member
OK - now you have created a new instance of a form...
The MainForm should be disabled:
MainForm.Enabled = False
After this you close the new instance created before and
then the MainForm should be re-enabled.
-
Apr 3rd, 2002, 11:35 AM
#5
vbzero, this is actualy the correct way to instanciate an object. In VB6 and earlier it was done by VB behind the scenes.
I really like the idea that you now have to do it the right way.
-
Apr 3rd, 2002, 04:49 PM
#6
I thought using showdialog to show a form disabled the parent form?
-
Apr 3rd, 2002, 05:16 PM
#7
Hyperactive Member
-scott
he he he
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
|