Click here to Skip to main content
15,893,161 members
Home / Discussions / C#
   

C#

 
QuestionHow to format a datetime to display day of week and date? Pin
Goalie355-May-11 10:39
Goalie355-May-11 10:39 
AnswerRe: How to format a datetime to display day of week and date? Pin
dbrenth5-May-11 10:51
dbrenth5-May-11 10:51 
AnswerRe: How to format a datetime to display day of week and date? Pin
Luc Pattyn5-May-11 10:51
sitebuilderLuc Pattyn5-May-11 10:51 
AnswerRe: How to format a datetime to display day of week and date? Pin
PIEBALDconsult5-May-11 16:17
mvePIEBALDconsult5-May-11 16:17 
AnswerRe: How to format a datetime to display day of week and date? Pin
Richard MacCutchan5-May-11 21:27
mveRichard MacCutchan5-May-11 21:27 
AnswerRe: How to format a datetime to display day of week and date? Pin
Goalie3511-May-11 5:00
Goalie3511-May-11 5:00 
QuestionHow to avoid closing mdiparent form while we close mdichild.? Pin
Paramu19735-May-11 4:21
Paramu19735-May-11 4:21 
AnswerRe: How to avoid closing mdiparent form while we close mdichild.? Pin
DaveyM695-May-11 7:17
professionalDaveyM695-May-11 7:17 
So you want this...
The user clicks the close button on the MdiParent and
if there are child forms open, close them all but leave the parent open
else close the parent & application
?

If so, this will do it. I have renamed the forms/controls to sensible names so the code is easier to follow.
C#
using System;
using System.Windows.Forms;

namespace MdiApplicationTest
{
    public partial class FormParent : Form
    {
        public FormParent()
        {
            InitializeComponent();
        }

        private void toolStripButtonNewChild_Click(object sender, EventArgs e)
        {
            FormChild child = new FormChild();
            child.MdiParent = this;
            child.Dock = DockStyle.Fill;
            child.Show();
        }

        private void FormParent_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MdiChildren.Length > 0)
            {
                foreach (Form form in MdiChildren)
                    form.Close();
                e.Cancel = true;
            }
        }
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



GeneralRe: How to avoid closing mdiparent form while we close mdichild.? Pin
Paramu19736-May-11 3:09
Paramu19736-May-11 3:09 
GeneralRe: How to avoid closing mdiparent form while we close mdichild.? Pin
DaveyM696-May-11 7:11
professionalDaveyM696-May-11 7:11 
GeneralRe: How to avoid closing mdiparent form while we close mdichild.? Pin
Paramu19736-May-11 7:53
Paramu19736-May-11 7:53 
QuestionHow to Apply Proerty in Control Pin
Anubhava Dimri5-May-11 0:12
Anubhava Dimri5-May-11 0:12 
AnswerRe: How to Apply Proerty in Control Pin
dasblinkenlight5-May-11 0:29
dasblinkenlight5-May-11 0:29 
AnswerRe: How to Apply Proerty in Control Pin
Ravi Sant5-May-11 0:36
Ravi Sant5-May-11 0:36 
QuestionAdd virtual device Pin
Pranit Kothari4-May-11 23:43
Pranit Kothari4-May-11 23:43 
AnswerRe: Add virtual device Pin
Dave Kreskowiak5-May-11 1:47
mveDave Kreskowiak5-May-11 1:47 
GeneralRe: Add virtual device Pin
Pranit Kothari5-May-11 1:57
Pranit Kothari5-May-11 1:57 
GeneralRe: Add virtual device Pin
fjdiewornncalwe5-May-11 3:00
professionalfjdiewornncalwe5-May-11 3:00 
AnswerRe: Add virtual device Pin
jschell5-May-11 8:14
jschell5-May-11 8:14 
QuestionWeb Service Returns Null, No Exceptions Pin
GlobX4-May-11 17:26
GlobX4-May-11 17:26 
Questionhow to add the values from controls to class to read it in xml Pin
Rocky234-May-11 7:42
Rocky234-May-11 7:42 
QuestionConversion of List to DataTable Pin
Ankit Rajput4-May-11 0:45
Ankit Rajput4-May-11 0:45 
AnswerRe: Conversion of List to DataTable Pin
Peter_in_27804-May-11 0:59
professionalPeter_in_27804-May-11 0:59 
GeneralRe: Conversion of List to DataTable Pin
Ankit Rajput4-May-11 1:02
Ankit Rajput4-May-11 1:02 
GeneralRe: Conversion of List to DataTable Pin
Dave Kreskowiak4-May-11 1:14
mveDave Kreskowiak4-May-11 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.