473,386 Members | 1,652 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,386 software developers and data experts.

Windows Forms - Opening forms within forms

In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?
--
Thanks,
Dan Tallent

Aug 26 '08 #1
21 3266
On Aug 26, 8:58*am, "Dan Tallent" <s...@microsoft.comwrote:
In my application I have a form (Customer) that I want to be able to open
multiple copies at once. *Within this form I have other forms that can be
opened. Example: ZipCode. * *When the user enters a zipcode that is unknown
this form will open. * I don't want users to modify any of this customers
data until they close the zipcode form. * Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?

--
Thanks,
Dan Tallent
I guess use a modeless form. Or, use a class in lieu of using
forms.

RL
Aug 26 '08 #2
I knew it must be a modeless form, otherwise the entire application is stuck
waiting.

As far as "use a class"...what do you mean? All objects are classes of
some kind.

This code
Child1 C = new Child1();C.StartPosition = FormStartPosition.CenterParent;

C.TopLevel = false;

C.Parent = this;

C.Top = (this.Height - C.Height) / 2;

C.Left = (this.Width - C.Width) / 2;

C.Show();

C.BringToFront();



"raylopez99" <ra********@yahoo.comwrote in message
news:5b**********************************@v26g2000 prm.googlegroups.com...
On Aug 26, 8:58 am, "Dan Tallent" <s...@microsoft.comwrote:
In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of
the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?

--
Thanks,
Dan Tallent
I guess use a modeless form. Or, use a class in lieu of using
forms.

RL
Aug 26 '08 #3
Unfortunately this code still allows the user to modify the part form. If
I set Enabled = false on the parent form it also kills the child form.

Any ideas?

Thanks
Dan


"Dan Tallent" <sp**@microsoft.comwrote in message
news:OU**************@TK2MSFTNGP02.phx.gbl...
>I knew it must be a modeless form, otherwise the entire application is
stuck waiting.

As far as "use a class"...what do you mean? All objects are classes of
some kind.

This code
Child1 C = new Child1();C.StartPosition = FormStartPosition.CenterParent;

C.TopLevel = false;

C.Parent = this;

C.Top = (this.Height - C.Height) / 2;

C.Left = (this.Width - C.Width) / 2;

C.Show();

C.BringToFront();



"raylopez99" <ra********@yahoo.comwrote in message
news:5b**********************************@v26g2000 prm.googlegroups.com...
On Aug 26, 8:58 am, "Dan Tallent" <s...@microsoft.comwrote:
>In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of
the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?

--
Thanks,
Dan Tallent

I guess use a modeless form. Or, use a class in lieu of using
forms.

RL

Aug 26 '08 #4
I'm sure there are other options, but you could have the Customer form have a
private instance of a Zipcode form. When the Customer form needs the Zipcode
form, it makes it visible. Change the enabled property of the Customer form
to false when the Zipcode form is shown. Add a handler for when the Zipcode
form is made invisible (VisibilityChanged), at which point the Customer form
becomes enabled.

"Dan Tallent" wrote:
In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?
--
Thanks,
Dan Tallent

Aug 26 '08 #5
Thanks for your reply.

I thought of something similar that when the ZipCode form was opened it
disabled the Customer form. The customer form subscribed to the FormClosed
event of the Zipcode form. This seems to work but it does have some
problems.
1 The Customer form can't be minimized or moved.
2 The Zipcode form can be moved outside the range of the Customer (parent)
form.
3 When you open a couple of customer forms it difficult (from a user point
of view) to tell which Customer screen the ZipCode is associated with.

If I could find a way to prevent the user from moving the ZipCode form
outside the boundries of the Customer form this would work perfectly. I
tried making the Customer form the parent, but when I disable the Customer
form the Zipcode form is disabled as well.

Thanks
dan

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:14**********************************@microsof t.com...
I'm sure there are other options, but you could have the Customer form
have a
private instance of a Zipcode form. When the Customer form needs the
Zipcode
form, it makes it visible. Change the enabled property of the Customer
form
to false when the Zipcode form is shown. Add a handler for when the
Zipcode
form is made invisible (VisibilityChanged), at which point the Customer
form
becomes enabled.

"Dan Tallent" wrote:
>In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is
unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of
the
Customer form while the zipcode form is open.

How do you normally go about handling this scenario ?
--
Thanks,
Dan Tallent


Aug 26 '08 #6
Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?
Aug 26 '08 #7
I looked into this method as well. I found I could use a form for the
ZipCode just as easily. The zipcode form can have its Parent set to the
Customer form which elimates the confusion. The form stays within the
boundry of the Customer form, and the Customer (parent) form can still be
minimized. The trick would be that I would need to write code to disable
all of the controls on the form manually. I have older apps that I've done
this with, but I was thinking I was doing this the hard way.

I suppose I could write a routine to loop though all the controls on the
form to disable/enable them. The problem there would be during the enable
knowing which controls should remain disabled.

Thanks for help. All suggestions are appreciated.
Dan


"G.S." <gs******@gmail.comwrote in message
news:22**********************************@c65g2000 hsa.googlegroups.com...
Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?

Aug 26 '08 #8
On Aug 26, 10:08*am, "Dan Tallent" <s...@microsoft.comwrote:
This code
Child1 C = new Child1();C.StartPosition = FormStartPosition.CenterParent;

C.TopLevel = false;

C.Parent = this;
Well there's your problem right there Dan. You are creating a
potential circular reference with the 'this' pointer on the RHS. By
the logic of your program (if I'm reading it correctly), the child
form has a member variable Parent, and you are essentially saying the
parent is the child. For the root node (first parent to every form,
or Form 1) I guess this is OK, but for every other subform it's not.

Did you program the lunar module that landed (or didn't) on Mars by
any chance?

RL
Aug 26 '08 #9
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like what you
are after.

"Dan Tallent" <sp**@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I looked into this method as well. I found I could use a form for the
ZipCode just as easily. The zipcode form can have its Parent set to the
Customer form which elimates the confusion. The form stays within the
boundry of the Customer form, and the Customer (parent) form can still be
minimized. The trick would be that I would need to write code to disable
all of the controls on the form manually. I have older apps that I've done
this with, but I was thinking I was doing this the hard way.

I suppose I could write a routine to loop though all the controls on the
form to disable/enable them. The problem there would be during the
enable knowing which controls should remain disabled.

Thanks for help. All suggestions are appreciated.
Dan


"G.S." <gs******@gmail.comwrote in message
news:22**********************************@c65g2000 hsa.googlegroups.com...
>Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?

Aug 26 '08 #10
This code exist on the parent. I believe this to be correct based on
several articles I've read.

What code would you propose be placed into the Parent form to open the child
form ?

"raylopez99" <ra********@yahoo.comwrote in message
news:74**********************************@8g2000hs e.googlegroups.com...
On Aug 26, 10:08 am, "Dan Tallent" <s...@microsoft.comwrote:
This code
Child1 C = new Child1();C.StartPosition = FormStartPosition.CenterParent;

C.TopLevel = false;

C.Parent = this;
Well there's your problem right there Dan. You are creating a
potential circular reference with the 'this' pointer on the RHS. By
the logic of your program (if I'm reading it correctly), the child
form has a member variable Parent, and you are essentially saying the
parent is the child. For the root node (first parent to every form,
or Form 1) I guess this is OK, but for every other subform it's not.

Did you program the lunar module that landed (or didn't) on Mars by
any chance?

RL
Aug 27 '08 #11
I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be in
the middle of working on an invoice and have to open a customer screen for a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability for
the rewrite.

I'm suprised this is not a more common question considering the
multi-tasking world we live in.

Thanks again for the help
Dan

"Family Tree Mike" <Fa************@ThisOldHouse.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like what you
are after.

"Dan Tallent" <sp**@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I looked into this method as well. I found I could use a form for the
ZipCode just as easily. The zipcode form can have its Parent set to the
Customer form which elimates the confusion. The form stays within the
boundry of the Customer form, and the Customer (parent) form can still be
minimized. The trick would be that I would need to write code to disable
all of the controls on the form manually. I have older apps that I've
done this with, but I was thinking I was doing this the hard way.

I suppose I could write a routine to loop though all the controls on the
form to disable/enable them. The problem there would be during the
enable knowing which controls should remain disabled.

Thanks for help. All suggestions are appreciated.
Dan


"G.S." <gs******@gmail.comwrote in message
news:22**********************************@c65g200 0hsa.googlegroups.com...
>>Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?


Aug 27 '08 #12
On Aug 26, 9:28*pm, "Dan Tallent" <s...@microsoft.comwrote:
I did think of that.. but discovered that it would not work. *I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. * The big issue will be a user might bein
the middle of working on an invoice and have to open a customer screen for a
completely different customer at the same time. *This is a fairly common
scenario with my current app, and I'm trying not to loose this ability for
the rewrite.

I'm suprised this is not a more common question considering the
multi-tasking world we live in.

Thanks again for the help
Dan

"Family Tree Mike" <FamilyTreeM...@ThisOldHouse.comwrote in messagenews:%2****************@TK2MSFTNGP05.phx.gb l...
Have you tried making Customer be an MDI Container? *It won't work if
Customer is contained within an MDI Container, but it sounds like what you
are after.
"Dan Tallent" <s...@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I looked into this method as well. * I found I could use a form for the
ZipCode just as easily. *The zipcode form can have its Parent set to the
Customer form which elimates the confusion. * The form stays within the
boundry of the Customer form, and the Customer (parent) form can still be
minimized. *The trick would be that I would need to write code to disable
all of the controls on the form manually. *I have older apps that I've
done this with, but I was thinking I was doing this the hard way.
I suppose I could write a routine to loop though all the controls on the
form to disable/enable them. * The problem there would be during the
enable knowing which controls should remain disabled.
Thanks for help. *All suggestions are appreciated.
Dan
"G.S." <gstoy...@gmail.comwrote in message
news:22**********************************@c65g200 0hsa.googlegroups.com....
Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?- Hide quoted text -

- Show quoted text -
I dont know off the top of my head, but I think you could place all
Customer controls in a container, leave the ZIP "modal" panel outside
that container and when you need to disable the Customer controls, you
only disable their container... one line. Now, again, I am not sure of
that and I don't currently have an easy way of checking...
Thinking about it, even if disabling the container doesn't work, the
fact they all belong to the same container (and the ZIP controls
don't) should make your looping strategy straight forward.
Aug 27 '08 #13
On Tue, 26 Aug 2008 18:28:59 -0700, Dan Tallent <sp**@microsoft.comwrote:
I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be
in
the middle of working on an invoice and have to open a customer screen
for a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability
for
the rewrite.

I'm suprised this is not a more common question considering the
multi-tasking world we live in.
All due respect, your intended design is contrary to practices typically
considered appropriate in good user-interface design. That's why it
doesn't come up much.

To recap: you want a window to be modal, but only relative to a particular
parent form, but you don't want there to be any indication that the modal
window is actually parented by that form (i.e. no MDI).

If the "ZIP" form is really modal, then let it be modal: make the user
complete that form before they are allowed to proceed to other input, even
in unrelated windows. This seems to me to be likely to be the best
approach. These modal forms shouldn't really be of the sort that there'd
be any good reason to leave them uncompleted for any lengthy period of
time. That is, modal forms are for specific user input, not something you
just leave lying around for a while.

Conversely, if you want to allow the user to proceed with other input
before completing the "ZIP" form (for example), then don't make it modal.

The fact is, you could in fact get this to work, and without too much
trouble too, by handling the modal behavior explicitly yourself in the
modal window's parent (i.e. disable the form, refuse focus/activation,
etc.) But really, if you've got a form that deserves being modal, then it
deserves to have the user finish using it before they move on to something
else. Doing it otherwise invites the user themselves to become confused
about what they are doing and where _their_ mental focus belongs. The
computer should help them organize their work, not encourage them to
become distracted and lost.

Pete
Aug 27 '08 #14
Yes, the code you posted is the typical way to asign the parent property to
the control.

"Dan Tallent" <sp**@microsoft.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
This code exist on the parent. I believe this to be correct based on
several articles I've read.

What code would you propose be placed into the Parent form to open the
child form ?

"raylopez99" <ra********@yahoo.comwrote in message
news:74**********************************@8g2000hs e.googlegroups.com...
On Aug 26, 10:08 am, "Dan Tallent" <s...@microsoft.comwrote:
>This code
Child1 C = new Child1();C.StartPosition = FormStartPosition.CenterParent;

C.TopLevel = false;

C.Parent = this;

Well there's your problem right there Dan. You are creating a
potential circular reference with the 'this' pointer on the RHS. By
the logic of your program (if I'm reading it correctly), the child
form has a member variable Parent, and you are essentially saying the
parent is the child. For the root node (first parent to every form,
or Form 1) I guess this is OK, but for every other subform it's not.

Did you program the lunar module that landed (or didn't) on Mars by
any chance?

RL
Aug 27 '08 #15
On Aug 26, 6:22*pm, "Dan Tallent" <s...@microsoft.comwrote:
This code exist on the parent. * *I believe this to be correct based on
several articles I've read.

What code would you propose be placed into the Parent form to open the child
form ?
If you've seen this work before, then leave it. But I usually do
something like this:

//in parent form:

FormMYCHILD frmChild = new FormMYCHILD();
frmChild.Show()

RL
Aug 27 '08 #16
Unfortunately this code does not place the new (child) form within the
parent itself. It is free to move everywhere including out of your
application and to the desktop.

Dan

"raylopez99" <ra********@yahoo.comwrote in message
news:26**********************************@59g2000h sb.googlegroups.com...
On Aug 26, 6:22 pm, "Dan Tallent" <s...@microsoft.comwrote:
This code exist on the parent. I believe this to be correct based on
several articles I've read.

What code would you propose be placed into the Parent form to open the
child
form ?
If you've seen this work before, then leave it. But I usually do
something like this:

//in parent form:

FormMYCHILD frmChild = new FormMYCHILD();
frmChild.Show()

RL
Aug 27 '08 #17
I think the loop with have to have a condition within it to ignore child
forms. I haven't written this code yet, but it seems likely.
Thanks for the help
Dan

"G.S." <gs******@gmail.comwrote in message
news:6b**********************************@a70g2000 hsh.googlegroups.com...
On Aug 26, 9:28 pm, "Dan Tallent" <s...@microsoft.comwrote:
I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be in
the middle of working on an invoice and have to open a customer screen for
a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability for
the rewrite.

I'm suprised this is not a more common question considering the
multi-tasking world we live in.

Thanks again for the help
Dan

"Family Tree Mike" <FamilyTreeM...@ThisOldHouse.comwrote in
messagenews:%2****************@TK2MSFTNGP05.phx.gb l...
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like what
you
are after.
"Dan Tallent" <s...@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I looked into this method as well. I found I could use a form for the
ZipCode just as easily. The zipcode form can have its Parent set to the
Customer form which elimates the confusion. The form stays within the
boundry of the Customer form, and the Customer (parent) form can still
be
minimized. The trick would be that I would need to write code to disable
all of the controls on the form manually. I have older apps that I've
done this with, but I was thinking I was doing this the hard way.
I suppose I could write a routine to loop though all the controls on
the
form to disable/enable them. The problem there would be during the
enable knowing which controls should remain disabled.
Thanks for help. All suggestions are appreciated.
Dan
"G.S." <gstoy...@gmail.comwrote in message
news:22**********************************@c65g200 0hsa.googlegroups.com...
Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default panel.
Then when your logic requires it, Show that panel while disabling the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?- Hide quoted text -

- Show quoted text -
I dont know off the top of my head, but I think you could place all
Customer controls in a container, leave the ZIP "modal" panel outside
that container and when you need to disable the Customer controls, you
only disable their container... one line. Now, again, I am not sure of
that and I don't currently have an easy way of checking...
Thinking about it, even if disabling the container doesn't work, the
fact they all belong to the same container (and the ZIP controls
don't) should make your looping strategy straight forward.

Aug 27 '08 #18
I am new to Windows form design in C#, and I fully admit I may be doing some
things wrong. This is why I am here getting advise from my peers. I have
searched hundreds of websites over the last week but felt like many people
ask the questions without receiving an acceptable answer. Many times the
people who initially posted the question never write in to report what
solution they found.
With that said....

I don't want the child form to be "modal" in the traditional sense because
it forces the user to finish and close this screen before they can work
anywhere else within the program.

You wrote:
To recap: you want a window to be modal, but only relative to a particular
parent form, but you don't want there to be any indication that the modal
window is actually parented by that form (i.e. no MDI).
This is not entirely correct. I don't want the form to be modal, however I
do not want the parent form editable while this (child) form is open. I
definately would prefer the child form to reside within the parent. I feel
the user interface would be clumsy and difficult to navigate otherwise.

My application will have its main MDI form that the entire application works
within. I don't want forms outside of the main MDI form. This MDI form
will have many child forms (Customer, Invoice, etc). These forms (Customer,
Invoice, etc) will have child forms of their own. (ZipCode, etc). Forms
like the Invoice form will have subforms that will be used for additional
data entry for the specific invoice. This type of interface is not
dissimilar to an Advanced button on many applications today. The average
user won't drill into this form, but sometimes the user will need use of
these Advanced features.
If I made these subforms modal then the user would be required to finish any
data entry before they could move anywhere else in the program. If the
phone rings and they need to look up a Customer, do you suggest they abandon
the changes on the subform so they can look up this customer? I feel they
should be able to open another instance of the Customer form to look up this
Customer who is calling.

Thanks
Dan


"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Tue, 26 Aug 2008 18:28:59 -0700, Dan Tallent <sp**@microsoft.com>
wrote:
>I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be
in
the middle of working on an invoice and have to open a customer screen
for a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability
for
the rewrite.

I'm suprised this is not a more common question considering the
multi-tasking world we live in.

All due respect, your intended design is contrary to practices typically
considered appropriate in good user-interface design. That's why it
doesn't come up much.

To recap: you want a window to be modal, but only relative to a particular
parent form, but you don't want there to be any indication that the modal
window is actually parented by that form (i.e. no MDI).

If the "ZIP" form is really modal, then let it be modal: make the user
complete that form before they are allowed to proceed to other input, even
in unrelated windows. This seems to me to be likely to be the best
approach. These modal forms shouldn't really be of the sort that there'd
be any good reason to leave them uncompleted for any lengthy period of
time. That is, modal forms are for specific user input, not something you
just leave lying around for a while.

Conversely, if you want to allow the user to proceed with other input
before completing the "ZIP" form (for example), then don't make it modal.

The fact is, you could in fact get this to work, and without too much
trouble too, by handling the modal behavior explicitly yourself in the
modal window's parent (i.e. disable the form, refuse focus/activation,
etc.) But really, if you've got a form that deserves being modal, then it
deserves to have the user finish using it before they move on to something
else. Doing it otherwise invites the user themselves to become confused
about what they are doing and where _their_ mental focus belongs. The
computer should help them organize their work, not encourage them to
become distracted and lost.

Pete

Aug 27 '08 #19
On Aug 27, 7:50*am, "Dan Tallent" <s...@microsoft.comwrote:
I think the loop with have to have a condition within it to ignore child
forms. *I haven't written this code yet, but it seems likely.
Thanks for the help
Dan

"G.S." <gstoy...@gmail.comwrote in message

news:6b**********************************@a70g2000 hsh.googlegroups.com...
On Aug 26, 9:28 pm, "Dan Tallent" <s...@microsoft.comwrote:


I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be in
the middle of working on an invoice and have to open a customer screen for
a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability for
the rewrite.
I'm suprised this is not a more common question considering the
multi-tasking world we live in.
Thanks again for the help
Dan
"Family Tree Mike" <FamilyTreeM...@ThisOldHouse.comwrote in
messagenews:%2****************@TK2MSFTNGP05.phx.gb l...
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like what
you
are after.
"Dan Tallent" <s...@microsoft.comwrote in message
>news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I looked into this method as well. I found I could use a form for the
>>ZipCode just as easily. The zipcode form can have its Parent set to the
>>Customer form which elimates the confusion. The form stays within the
>>boundry of the Customer form, and the Customer (parent) form can still
>>be
>>minimized. The trick would be that I would need to write code to disable
>>all of the controls on the form manually. I have older apps that I've
>>done this with, but I was thinking I was doing this the hard way.
>I suppose I could write a routine to loop though all the controls on
>the
>form to disable/enable them. The problem there would be during the
>enable knowing which controls should remain disabled.
>Thanks for help. All suggestions are appreciated.
>Dan
>"G.S." <gstoy...@gmail.comwrote in message
>>news:22**********************************@c65g20 00hsa.googlegroups.com...
>>Why don't you try redesigning abit. Make the "ZIP form" a user
>>control. Then on your Customer form center a hidden by default panel.
>>Then when your logic requires it, Show that panel while disabling the
>>rest of the controls behind it. The Customer form can still be
>>minimized, the ZIP *panel* is really part of form's layout, so no
>>confusion which ZIP panel belongs to which Customer form...
>>Will that work?- Hide quoted text -
- Show quoted text -

I dont know off the top of my head, but I think you could place all
Customer controls in a container, leave the ZIP "modal" panel outside
that container and when you need to disable the Customer controls, you
only disable their container... one line. Now, again, I am not sure of
that and I don't currently have an easy way of checking...
Thinking about it, even if disabling the container doesn't work, the
fact they all belong to the same container (and the ZIP controls
don't) should make your looping strategy straight forward.- Hide quoted text -

- Show quoted text -
While I agree to a degree with Peter Duniho on the possibility of
cluttered screen, I think that keeping the ZIP as a panel inside the
form diminishes that clutter.

And yes, the panel does have Enabled property.

Here's a working example. button1 is on the "main" form and switches
to modal panel, button2 is on the modal panel and switches back to
main form view. Of course you can play with panel positions.

using System;
using System.Windows.Forms;

namespace ModalPanel
{
public class Form1 : Form
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new Form1());
}

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ShowModalPanel(true);
}

private void button2_Click(object sender, EventArgs e)
{
ShowModalPanel(false);
}

private void ShowModalPanel(bool show)
{
panelMainForm.Enabled = !show;
panelModal.Visible = show;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panelMainForm = new System.Windows.Forms.Panel();
this.panelModal = new System.Windows.Forms.Panel();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.panelMainForm.SuspendLayout();
this.panelModal.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// panelMainForm
//
this.panelMainForm.Controls.Add(this.label1);
this.panelMainForm.Controls.Add(this.button1);
this.panelMainForm.Controls.Add(this.groupBox1);
this.panelMainForm.Location = new System.Drawing.Point(34, 30);
this.panelMainForm.Name = "panelMainForm";
this.panelMainForm.Size = new System.Drawing.Size(292, 361);
this.panelMainForm.TabIndex = 0;
//
// panelModal
//
this.panelModal.Controls.Add(this.button2);
this.panelModal.Controls.Add(this.textBox2);
this.panelModal.Controls.Add(this.checkBox1);
this.panelModal.Location = new System.Drawing.Point(332, 124);
this.panelModal.Name = "panelModal";
this.panelModal.Size = new System.Drawing.Size(200, 141);
this.panelModal.TabIndex = 0;
this.panelModal.Visible = false;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(37, 74);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Location = new System.Drawing.Point(15, 44);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(261, 125);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 295);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(7, 20);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(7, 44);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(15, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(97, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1 label1 label1";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(7, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(37, 42);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(41, 108);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 433);
this.Controls.Add(this.panelModal);
this.Controls.Add(this.panelMainForm);
this.Name = "Form1";
this.Text = "Form1";
this.panelMainForm.ResumeLayout(false);
this.panelMainForm.PerformLayout();
this.panelModal.ResumeLayout(false);
this.panelModal.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Panel panelMainForm;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Panel panelModal;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button2;
}
}
Aug 27 '08 #20
I appreciate the help.

I currently have code that is using a child form (ZipCode) within the parent
(Customer)

When the child closes the parent comes back to life. The child has its
FormBorderStyle = FixedToolWindow and cannot move outside the area of the
parent (Customer).
This approach seems to be working. It also allows me to use the ZipCode
form in other locations within the program such as for a Vendors address.
If the Customer form is minimized or moved the ZipCode form travels with it.
I am thinking of using an Inherited version of the form class so I can add
the Active method for use in all of the forms.

I have not attempted to Inherit from a control before and I'm not sure how I
will be able to use it within the IDE.....yet.

Thanks everyone for your help. If you see any problems with this approach
please feel free to point them out.

Thanks again,
Dan
//---------------------------------------------------------------------------

private void button4_Click(object sender, EventArgs e)

{

this.Active(false);

Child1 C = new Child1();

C.FormClosed+=new FormClosedEventHandler(C_FormClosed);

C.TopLevel = false;
C.Parent = this;

C.Top = (this.MdiParent.Top + (this.Height - C.Height) / 2);

C.Left = (this.MdiParent.Left + (this.Width - C.Width) / 2);

C.BringToFront();

C.Show();

}

void C_FormClosed(object sender, FormClosedEventArgs e)

{
this.Active(true);
}

private void Active(bool status)

{

foreach (Control oControl in this.Controls)

{

oControl.Enabled = status;
}

}

//---------------------------------------------------------------------------



"G.S." <gs******@gmail.comwrote in message
news:7c**********************************@m45g2000 hsb.googlegroups.com...
On Aug 27, 7:50 am, "Dan Tallent" <s...@microsoft.comwrote:
I think the loop with have to have a condition within it to ignore child
forms. I haven't written this code yet, but it seems likely.
Thanks for the help
Dan

"G.S." <gstoy...@gmail.comwrote in message

news:6b**********************************@a70g2000 hsh.googlegroups.com...
On Aug 26, 9:28 pm, "Dan Tallent" <s...@microsoft.comwrote:


I did think of that.. but discovered that it would not work. I am at the
very beginning stages of writting this app, but the end result will have
something like 60 unique forms. The big issue will be a user might be in
the middle of working on an invoice and have to open a customer screen
for
a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability
for
the rewrite.
I'm suprised this is not a more common question considering the
multi-tasking world we live in.
Thanks again for the help
Dan
"Family Tree Mike" <FamilyTreeM...@ThisOldHouse.comwrote in
messagenews:%2****************@TK2MSFTNGP05.phx.gb l...
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like what
you
are after.
"Dan Tallent" <s...@microsoft.comwrote in message
>news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I looked into this method as well. I found I could use a form for the
>>ZipCode just as easily. The zipcode form can have its Parent set to
>>the
>>Customer form which elimates the confusion. The form stays within the
>>boundry of the Customer form, and the Customer (parent) form can still
>>be
>>minimized. The trick would be that I would need to write code to
>>disable
>>all of the controls on the form manually. I have older apps that I've
>>done this with, but I was thinking I was doing this the hard way.
>I suppose I could write a routine to loop though all the controls on
>the
>form to disable/enable them. The problem there would be during the
>enable knowing which controls should remain disabled.
>Thanks for help. All suggestions are appreciated.
>Dan
>"G.S." <gstoy...@gmail.comwrote in message
>>news:22**********************************@c65g20 00hsa.googlegroups.com...
>>Why don't you try redesigning abit. Make the "ZIP form" a user
>>control. Then on your Customer form center a hidden by default
>>panel.
>>Then when your logic requires it, Show that panel while disabling
>>the
>>rest of the controls behind it. The Customer form can still be
>>minimized, the ZIP *panel* is really part of form's layout, so no
>>confusion which ZIP panel belongs to which Customer form...
>>Will that work?- Hide quoted text -
- Show quoted text -

I dont know off the top of my head, but I think you could place all
Customer controls in a container, leave the ZIP "modal" panel outside
that container and when you need to disable the Customer controls, you
only disable their container... one line. Now, again, I am not sure of
that and I don't currently have an easy way of checking...
Thinking about it, even if disabling the container doesn't work, the
fact they all belong to the same container (and the ZIP controls
don't) should make your looping strategy straight forward.- Hide quoted
text -

- Show quoted text -
While I agree to a degree with Peter Duniho on the possibility of
cluttered screen, I think that keeping the ZIP as a panel inside the
form diminishes that clutter.

And yes, the panel does have Enabled property.

Here's a working example. button1 is on the "main" form and switches
to modal panel, button2 is on the modal panel and switches back to
main form view. Of course you can play with panel positions.

using System;
using System.Windows.Forms;

namespace ModalPanel
{
public class Form1 : Form
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new Form1());
}

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ShowModalPanel(true);
}

private void button2_Click(object sender, EventArgs e)
{
ShowModalPanel(false);
}

private void ShowModalPanel(bool show)
{
panelMainForm.Enabled = !show;
panelModal.Visible = show;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panelMainForm = new System.Windows.Forms.Panel();
this.panelModal = new System.Windows.Forms.Panel();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.panelMainForm.SuspendLayout();
this.panelModal.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// panelMainForm
//
this.panelMainForm.Controls.Add(this.label1);
this.panelMainForm.Controls.Add(this.button1);
this.panelMainForm.Controls.Add(this.groupBox1);
this.panelMainForm.Location = new System.Drawing.Point(34, 30);
this.panelMainForm.Name = "panelMainForm";
this.panelMainForm.Size = new System.Drawing.Size(292, 361);
this.panelMainForm.TabIndex = 0;
//
// panelModal
//
this.panelModal.Controls.Add(this.button2);
this.panelModal.Controls.Add(this.textBox2);
this.panelModal.Controls.Add(this.checkBox1);
this.panelModal.Location = new System.Drawing.Point(332, 124);
this.panelModal.Name = "panelModal";
this.panelModal.Size = new System.Drawing.Size(200, 141);
this.panelModal.TabIndex = 0;
this.panelModal.Visible = false;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(37, 74);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Location = new System.Drawing.Point(15, 44);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(261, 125);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 295);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(7, 20);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(7, 44);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(15, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(97, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1 label1 label1";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(7, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(37, 42);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(41, 108);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 433);
this.Controls.Add(this.panelModal);
this.Controls.Add(this.panelMainForm);
this.Name = "Form1";
this.Text = "Form1";
this.panelMainForm.ResumeLayout(false);
this.panelMainForm.PerformLayout();
this.panelModal.ResumeLayout(false);
this.panelModal.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Panel panelMainForm;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Panel panelModal;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button2;
}
}
Aug 27 '08 #21
I just realized I used the MdiParent property for setting this location.
This was something I was playing with. It should just be Parent
"Dan Tallent" <sp**@microsoft.comwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
>I appreciate the help.

I currently have code that is using a child form (ZipCode) within the
parent (Customer)

When the child closes the parent comes back to life. The child has its
FormBorderStyle = FixedToolWindow and cannot move outside the area of the
parent (Customer).
This approach seems to be working. It also allows me to use the ZipCode
form in other locations within the program such as for a Vendors address.
If the Customer form is minimized or moved the ZipCode form travels with
it. I am thinking of using an Inherited version of the form class so I can
add the Active method for use in all of the forms.

I have not attempted to Inherit from a control before and I'm not sure how
I will be able to use it within the IDE.....yet.

Thanks everyone for your help. If you see any problems with this
approach please feel free to point them out.

Thanks again,
Dan
//---------------------------------------------------------------------------

private void button4_Click(object sender, EventArgs e)

{

this.Active(false);

Child1 C = new Child1();

C.FormClosed+=new FormClosedEventHandler(C_FormClosed);

C.TopLevel = false;
C.Parent = this;

C.Top = (this.MdiParent.Top + (this.Height - C.Height) / 2);

C.Left = (this.MdiParent.Left + (this.Width - C.Width) / 2);

C.BringToFront();

C.Show();

}

void C_FormClosed(object sender, FormClosedEventArgs e)

{
this.Active(true);
}

private void Active(bool status)

{

foreach (Control oControl in this.Controls)

{

oControl.Enabled = status;
}

}

//---------------------------------------------------------------------------



"G.S." <gs******@gmail.comwrote in message
news:7c**********************************@m45g2000 hsb.googlegroups.com...
On Aug 27, 7:50 am, "Dan Tallent" <s...@microsoft.comwrote:
>I think the loop with have to have a condition within it to ignore child
forms. I haven't written this code yet, but it seems likely.
Thanks for the help
Dan

"G.S." <gstoy...@gmail.comwrote in message

news:6b**********************************@a70g200 0hsh.googlegroups.com...
On Aug 26, 9:28 pm, "Dan Tallent" <s...@microsoft.comwrote:


I did think of that.. but discovered that it would not work. I am at
the
very beginning stages of writting this app, but the end result will
have
something like 60 unique forms. The big issue will be a user might be
in
the middle of working on an invoice and have to open a customer screen
for
a
completely different customer at the same time. This is a fairly common
scenario with my current app, and I'm trying not to loose this ability
for
the rewrite.
I'm suprised this is not a more common question considering the
multi-tasking world we live in.
Thanks again for the help
Dan
"Family Tree Mike" <FamilyTreeM...@ThisOldHouse.comwrote in
messagenews:%2****************@TK2MSFTNGP05.phx.gb l...
Have you tried making Customer be an MDI Container? It won't work if
Customer is contained within an MDI Container, but it sounds like
what
you
are after.
"Dan Tallent" <s...@microsoft.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I looked into this method as well. I found I could use a form for the
ZipCode just as easily. The zipcode form can have its Parent set to
the
Customer form which elimates the confusion. The form stays within the
boundry of the Customer form, and the Customer (parent) form can
still
be
minimized. The trick would be that I would need to write code to
disable
all of the controls on the form manually. I have older apps that I've
done this with, but I was thinking I was doing this the hard way.
>I suppose I could write a routine to loop though all the controls on
the
form to disable/enable them. The problem there would be during the
enable knowing which controls should remain disabled.
>Thanks for help. All suggestions are appreciated.
Dan
>"G.S." <gstoy...@gmail.comwrote in message
news:22**********************************@c65g20 00hsa.googlegroups.com...
Why don't you try redesigning abit. Make the "ZIP form" a user
control. Then on your Customer form center a hidden by default
panel.
Then when your logic requires it, Show that panel while disabling
the
rest of the controls behind it. The Customer form can still be
minimized, the ZIP *panel* is really part of form's layout, so no
confusion which ZIP panel belongs to which Customer form...
Will that work?- Hide quoted text -
- Show quoted text -

I dont know off the top of my head, but I think you could place all
Customer controls in a container, leave the ZIP "modal" panel outside
that container and when you need to disable the Customer controls, you
only disable their container... one line. Now, again, I am not sure of
that and I don't currently have an easy way of checking...
Thinking about it, even if disabling the container doesn't work, the
fact they all belong to the same container (and the ZIP controls
don't) should make your looping strategy straight forward.- Hide quoted
text -

- Show quoted text -

While I agree to a degree with Peter Duniho on the possibility of
cluttered screen, I think that keeping the ZIP as a panel inside the
form diminishes that clutter.

And yes, the panel does have Enabled property.

Here's a working example. button1 is on the "main" form and switches
to modal panel, button2 is on the modal panel and switches back to
main form view. Of course you can play with panel positions.

using System;
using System.Windows.Forms;

namespace ModalPanel
{
public class Form1 : Form
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new Form1());
}

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ShowModalPanel(true);
}

private void button2_Click(object sender, EventArgs e)
{
ShowModalPanel(false);
}

private void ShowModalPanel(bool show)
{
panelMainForm.Enabled = !show;
panelModal.Visible = show;
}

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panelMainForm = new System.Windows.Forms.Panel();
this.panelModal = new System.Windows.Forms.Panel();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.panelMainForm.SuspendLayout();
this.panelModal.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// panelMainForm
//
this.panelMainForm.Controls.Add(this.label1);
this.panelMainForm.Controls.Add(this.button1);
this.panelMainForm.Controls.Add(this.groupBox1);
this.panelMainForm.Location = new System.Drawing.Point(34, 30);
this.panelMainForm.Name = "panelMainForm";
this.panelMainForm.Size = new System.Drawing.Size(292, 361);
this.panelMainForm.TabIndex = 0;
//
// panelModal
//
this.panelModal.Controls.Add(this.button2);
this.panelModal.Controls.Add(this.textBox2);
this.panelModal.Controls.Add(this.checkBox1);
this.panelModal.Location = new System.Drawing.Point(332, 124);
this.panelModal.Name = "panelModal";
this.panelModal.Size = new System.Drawing.Size(200, 141);
this.panelModal.TabIndex = 0;
this.panelModal.Visible = false;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(37, 74);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Location = new System.Drawing.Point(15, 44);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(261, 125);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 295);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(7, 20);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(7, 44);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(15, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(97, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1 label1 label1";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(7, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(37, 42);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(41, 108);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 433);
this.Controls.Add(this.panelModal);
this.Controls.Add(this.panelMainForm);
this.Name = "Form1";
this.Text = "Form1";
this.panelMainForm.ResumeLayout(false);
this.panelMainForm.PerformLayout();
this.panelModal.ResumeLayout(false);
this.panelModal.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Panel panelMainForm;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.Panel panelModal;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button2;
}
}

Aug 27 '08 #22

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

Similar topics

2
by: dsnyder | last post by:
This HTML has a bit of Javascript at the end that puts the initial focus on the userID field. It works great on Windows2000 running IE6, but the initial focus never goes to the userID field on...
4
by: Jelmer | last post by:
Hi I've been trying to create an addin similar to Find & Replace from Rick Fisher that looks thru your tables / queries / forms / modules etc.. for a reference to a string and optionally let's you...
19
by: Lauren Quantrell | last post by:
In Windows XP display Properties/Appearance users can chose between: Windows XP Style or Windows Classic Style. Is there a way in VBA to determine the user's selection? The reason: Toolbars...
3
by: Vitaly Zayko | last post by:
Is it possible to attach a form (C# .NET 2) to windows service and show it in OnStart event? When I tried to do this in general (new, Show()) way it just didn't do anything nor gave me any errors....
3
by: TheSteph | last post by:
Using : VS 2005, .NET 2.0, Windows Form, Win 2k I have a strange problem in VS : When I open some forms all the files (resx and cs) of this form are immediately marked as modified (an *...
2
by: Budhi Saputra Prasetya | last post by:
Hi, I managed to create a Windows Form Control and put it on my ASP .NET page. I have done the suggestion that is provided by modifying the security settings. From the stack trace, I would...
0
by: Budhi Saputra Prasetya | last post by:
Hi, I still have the same problem with embedding Windows Control. I'll just requote what I posted last time: I managed to create a Windows Form Control and put it on my ASP .NET page. I...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
9
by: Scott Stark | last post by:
Hello, I'm *just* delving into Windows forms-based programming without the benefit of any books, etc. I have a background in light ASP.NET work, so forgive me if this is a really basic question...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.