Saber37886661
asked on
Forms bloody Forms
Hi everyone,
I currently find myself having to build a windows application and unfortunetly lack the experience with forms.
So, what I have is a mdi container and in this container the user can open up and number of forms, but I want to be able to limit them to 10 forms, and be able to reuse these forms as they may be able to open x versions of the same form at a time.
I suppose I need some tpe of queue.
I have tried declaring the forms pointing to a dummy form I have ie.
blah.blankForm = f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
but then when I want to assign f1 to a different for it chucks an error
f1 = new dummyForm();
I have no idea how else to approach this. So any help would be fantastic.
Cheers
Matt
I currently find myself having to build a windows application and unfortunetly lack the experience with forms.
So, what I have is a mdi container and in this container the user can open up and number of forms, but I want to be able to limit them to 10 forms, and be able to reuse these forms as they may be able to open x versions of the same form at a time.
I suppose I need some tpe of queue.
I have tried declaring the forms pointing to a dummy form I have ie.
blah.blankForm = f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
but then when I want to assign f1 to a different for it chucks an error
f1 = new dummyForm();
I have no idea how else to approach this. So any help would be fantastic.
Cheers
Matt
Please post your code along with the error message. It's much easier to help you if we can see the code
ASKER
magicdlf I have no code if I did then chances are I could figure it out myself. I only know the concept of what I want to do but have no idea how to implement it.
Please read my problem again.
Please read my problem again.
What I would do is intercept the OnNewDocument and OnOpenDocument calls. Then count how many documents are currently opened, if it is at your limit (eg. 10) then take whatever action you want.
(Junking what is in an open document could annoy the user - it really depends on what they are and how people work with them).
(Junking what is in an open document could annoy the user - it really depends on what they are and how people work with them).
ASKER
Hi Andy,
I can count the open forms fine, but I dont know how to declare them all as non specific forms.
Ill try and explain again, I am not sure if this confusion is me not explaining this right.
Say you have a mdi parent form. It has say 30 different options off the menu, all which open a new form.
But I only want to be able to have 10 forms open at a time, and I want to be able to have 10 copies of 1 type of form open if I want.
So say for example My menu's first item is User Controls. Clicking this would open a form called UserControls. Normally you would have somethign like:
UserControls frmUserControls = new UserControls();
frmUserControls.MdiParent = this;
frmUserControls.Show()
But for me to then allow 10 versions of the forms to open then I would need 10 seperate declarations of the form. That would mean 300 form declarations.
So rather then do that, I want to be able to have 10 blank public forms declared that I can then dynamically assign the form to.
so for instance
frm1, frm2, frm3, frm4, frm5, frm6, frm7, frm8, frm9, frm10 would all be blank public forms
then I could assign the new form to it when it was needed like
frm1 = new UserControls();
frmUserControls.MdiParent = this;
frmUserControls.Show()
Does that make it a bit less confusing?
I can count the open forms fine, but I dont know how to declare them all as non specific forms.
Ill try and explain again, I am not sure if this confusion is me not explaining this right.
Say you have a mdi parent form. It has say 30 different options off the menu, all which open a new form.
But I only want to be able to have 10 forms open at a time, and I want to be able to have 10 copies of 1 type of form open if I want.
So say for example My menu's first item is User Controls. Clicking this would open a form called UserControls. Normally you would have somethign like:
UserControls frmUserControls = new UserControls();
frmUserControls.MdiParent = this;
frmUserControls.Show()
But for me to then allow 10 versions of the forms to open then I would need 10 seperate declarations of the form. That would mean 300 form declarations.
So rather then do that, I want to be able to have 10 blank public forms declared that I can then dynamically assign the form to.
so for instance
frm1, frm2, frm3, frm4, frm5, frm6, frm7, frm8, frm9, frm10 would all be blank public forms
then I could assign the new form to it when it was needed like
frm1 = new UserControls();
frmUserControls.MdiParent = this;
frmUserControls.Show()
Does that make it a bit less confusing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Andy,
I have no idea if what you said was right but I got it working right.
After seeing what you wrote the penny dropped and my problem was that I was declaring the forms down to the nth degree when I needn't.
Just declaring:
Form f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
is enough because then I can assign to them at will like:
switch (sender.ToString())
{
case "User Login History":
f1 = new WebRD_Client.admin.User.Us erHistory( );
f1.MdiParent = this;
f1.Show();
break;
case "User Tools":
f1.Close();
f1.Dispose();
f1 = new WebRD_Client.admin.User.Us erTools();
f1.MdiParent = this;
f1.Show();
break;
}
(I havent worried about the checking to see what form is empty yet)
So thankyou for your help :)
I have no idea if what you said was right but I got it working right.
After seeing what you wrote the penny dropped and my problem was that I was declaring the forms down to the nth degree when I needn't.
Just declaring:
Form f1, f2, f3, f4, f5, f6, f7, f8, f9, f10;
is enough because then I can assign to them at will like:
switch (sender.ToString())
{
case "User Login History":
f1 = new WebRD_Client.admin.User.Us
f1.MdiParent = this;
f1.Show();
break;
case "User Tools":
f1.Close();
f1.Dispose();
f1 = new WebRD_Client.admin.User.Us
f1.MdiParent = this;
f1.Show();
break;
}
(I havent worried about the checking to see what form is empty yet)
So thankyou for your help :)
ASKER
Thanks alot for your help :)