Resizing mdiChild form affects the other mdiChild form - c#

I am creating an MDI application in which it has multiple mdiChild forms. When I resize one mdiChild form, it affects the other mdiChild forms.. How can I solve this? There are a lot of questions about mdichild forms here but none of them seems to be the same case as i have.
Example :
When i maximize one mdiChild form, the other will maximize too even though they are set to normal window state already..
EDIT
This is the mdiParent codes where i call the mdiChild forms.
private void editAccountToolStripMenuItem_Click(object sender, EventArgs e)
{
AdminForms.Dialogs.FrmAdminEdit adminedit = new AdminForms.Dialogs.FrmAdminEdit();
adminedit.Show();
adminedit.MdiParent = this;
}
private void listOfCandidatesToolStripMenuItem_Click(object sender, EventArgs e)
{
AdminForms.Dialogs.FrmCandidate cand = new AdminForms.Dialogs.FrmCandidate();
cand.Show();
cand.MdiParent = this;
}
But in run-time, when i resize one of the mdichild, the other mdichild forms are resizing too.. if maximize button is clicked, all of the mdichild will be maximized.
I want the mdiChild that I resize, do not affect the other mdiChild forms..

Related

Multiple forms in the same window in C#

I'm interested in the way to make some sub-forms, like child forms (for example, helper form that shows when you click on a find button and want to search through the suppliers).
But I don't want it to create another "window" in the taskbar, but to be integrated in the main form.
I know about Show() and ShowDialog(), but it opens another window in the taskbar...
I tried with MDI and was able to make it, but I don't want to use MDI.
So, can someone provide some knowledge about some alternative?
I've seen examples of this in some programs, but I don't know how is this achieved. I'm pretty new to visual C#.
For your other form use the ShowInTaskbar property and set it to false
this.ShowInTaskbar = false;
Then you can either use Show() or ShowDialog()
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
}

How to create a full-screen form with max/min/close button in c#?

I made full-screen by: FormBorderStyle = FormBorderStyle.None;
but there is no max/min/close button? How to get it?
Set the WindowState property of your form to Maximized instead of removing the form border if you want a full screen form to retain the controls.
private void Form1_Shown(object sender, EventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
If you actually want a full screen form with no border the best way to do this would likely be a custom user control to emulate the standard min/max/close functions.

How do I hide or close the MDI parent?

In my project I have a MDI parent form, from that form I jump in my main program but when I enter my main program I want to close, hide or minimize the MDI , so it isn't visible for the user. I tried it by myself but it didn't work. I was wondering if it is possible and how it is possible.
private void bot45_Click(object sender, EventArgs e)
{
Form2 fors = new Form2(); //main program
fors.Show();
//bot 45 is the button to enter the main form
// enter main program--->> code to hide close or minimize the MDI form
}

How can I maximize the form at run time

How can I maximize the form at run time?
I have one panel in form 1 . I want to show form 2 (Rule_form) in this panel on button click.
I have write this code on button click:
Rule_form rule = new Rule_form();
rule.Show();
rule.TopLevel = false;
rule.WindowState = FormWindowState.Maximized;
rule.FormBorderStyle = FormBorderStyle.None;
internal_pannel.Controls.Add(rule);
But it doesn't work. When I click on button form 2 (Rule_form) opens with it's default size.
How can I maximize a form 2 (Rule_form) with panel size at start up?
I think you should run rule.Show(); at last.
Because now the form get showed before it is maximized.
That explains your problem.
What if you call rule.show after setting the windowstate or formborderstyle.
That is supposed to work.
You can also create an load event for the new form. And in this load event set the form to be maximized. Like this:
private void Rule_form_Load(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}

C# Form Problem: new form losing control and randomly hiding

I'm encountering strange behavior with forms on a c# 3.5 app. On a button click, my form1 hides itself, creates a new form2, and shows form2. Form1 also contains the event method triggered when form2 closes. Here's the code inside Form1:
Form2 form2;
void button1_Click(object sender, EventArgs e)
{
this.Hide();
form2 = new form2();
form2.Show();
form2.FormClosed += new FormClosedEventHandler(form2_FormClosed);
}
void form2_FormClosed(object sender, FormClosedEventArgs e)
{
form2.Dispose();
form2 = null;
this.Show();
}
Now, my problem is that sometimes when I open form2 (hiding form1), or when I close form2 (showing form1), the new form will come up on the screen for a blink and then hide itself. It's still open and I can click it from the taskbar to show it again, but the window itself is sent behind any other open windows. It looks like it opens up but minimizes instantly.
This behavior occurs randomly. Sometimes forms will open up and hide without a problem, but sometimes they'll lose focus over another window. I've tried using focus(), activate(), and topmost but all have failed to prevent the sudden hiding.
Does anyone know why is this happening and how to fix it?
Thanks.
You hide your form too soon. For a brief moment, your app has no window that can contain the focus. That forces Windows to go hunting for another window to give the focus to, it will pick one from another application. That window will now be the foreground window, your second form will not get the focus and appear lower in the Z-order. The fix is simple:
void button1_Click(object sender, EventArgs e)
{
form2 = new form2();
form2.Show();
form2.FormClosed += new FormClosedEventHandler(form2_FormClosed);
this.Hide(); // Moved
}

Categories

Resources