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;
}
}