Click here to Skip to main content
15,881,898 members
Home / Discussions / C#
   

C#

 
QuestionHow to investigate ExecutionEngineException Pin
KASR11-Feb-13 22:21
KASR11-Feb-13 22:21 
AnswerRe: How to investigate ExecutionEngineException Pin
Richard MacCutchan1-Feb-13 22:55
mveRichard MacCutchan1-Feb-13 22:55 
QuestionMdi Child Window Z-Order Pin
Richard Andrew x641-Feb-13 12:16
professionalRichard Andrew x641-Feb-13 12:16 
AnswerRe: Mdi Child Window Z-Order Pin
Jibesh1-Feb-13 12:43
professionalJibesh1-Feb-13 12:43 
GeneralRe: Mdi Child Window Z-Order Pin
Richard Andrew x641-Feb-13 13:08
professionalRichard Andrew x641-Feb-13 13:08 
GeneralRe: Mdi Child Window Z-Order Pin
Jibesh1-Feb-13 13:10
professionalJibesh1-Feb-13 13:10 
AnswerRe: Mdi Child Window Z-Order Pin
DaveyM691-Feb-13 23:57
professionalDaveyM691-Feb-13 23:57 
AnswerRe: Mdi Child Window Z-Order Pin
Alan N2-Feb-13 6:17
Alan N2-Feb-13 6:17 
After a bit of rooting around in the undergrowth of the outer form, I've found the ordered list of MDI windows.

The Form.MdiChildren property is a list of MDI children but the order is fixed in order in which the forms were created.

Enumeration of the Form.Controls collection will reveal an unnamed Control of type System.Windows.Forms.MdiClient whose Controls collection is the dynamically ordered list of MDI child forms. The first item is the form at the top of the Z-order.

C#
private void ShowMdiChildren() {
  // 'log' is a TextWriter
  log.WriteLine("MdiClient control collection");
  log.WriteLine("============================");
  foreach (Control c in this.Controls) {
    if (c is System.Windows.Forms.MdiClient) {
      System.Windows.Forms.Control.ControlCollection mdiColl = c.Controls;

      // Write:  Index  Text  Name  Type
      foreach (Control mdiChild in mdiColl) {
        log.WriteLine("{0,-2} {1, -20} {2, -16} {3}", mdiColl.GetChildIndex(mdiChild), mdiChild.Text, mdiChild.Name, mdiChild.GetType());
      }

      // equivalent code
      //for (Int32 index = 0; index < mdiColl.Count; index++) {
      //  Control child = mdiColl[index];
      //  log.WriteLine("{0,-2} {1, -20} {2, -16} {3}", index, child.Text, child.Name, child.GetType());
      //}
    }
  }
  log.WriteLine();
}


By manipulation of the collection you can do fun things like reorder the child forms
C#
private void RotateZOrder() {
  foreach (Control c in this.Controls) {
    if (c is MdiClient) {
      // send index 0 (front) to back
      Control.ControlCollection mdiColl = c.Controls;
      if (mdiColl.Count >= 2) {
        mdiColl.SetChildIndex(mdiColl[0], mdiColl.Count - 1);
      }
    }
  }
}

Alan.
QuestionStrip special characters in row of data Pin
vanikanc1-Feb-13 5:41
vanikanc1-Feb-13 5:41 
AnswerRe: Strip special characters in row of data Pin
Eddy Vluggen1-Feb-13 6:53
professionalEddy Vluggen1-Feb-13 6:53 
AnswerRe: Strip special characters in row of data Pin
Ennis Ray Lynch, Jr.1-Feb-13 8:15
Ennis Ray Lynch, Jr.1-Feb-13 8:15 
QuestionC#,ASP.Net Pin
sujeet3211-Feb-13 0:51
sujeet3211-Feb-13 0:51 
AnswerRe: C#,ASP.Net Pin
Simon_Whale1-Feb-13 1:06
Simon_Whale1-Feb-13 1:06 
AnswerRe: C#,ASP.Net Pin
Dave Kreskowiak1-Feb-13 1:30
mveDave Kreskowiak1-Feb-13 1:30 
AnswerRe: C#,ASP.Net Pin
Abhinav S1-Feb-13 8:16
Abhinav S1-Feb-13 8:16 
Questionhow to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 21:37
NarVish31-Jan-13 21:37 
AnswerRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 22:21
mveOriginalGriff31-Jan-13 22:21 
GeneralRe: how to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 22:35
NarVish31-Jan-13 22:35 
GeneralRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 22:38
mveOriginalGriff31-Jan-13 22:38 
GeneralRe: how to change the background color of a selected row in datagridview Pin
Richard MacCutchan31-Jan-13 22:39
mveRichard MacCutchan31-Jan-13 22:39 
GeneralRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 22:46
mveOriginalGriff31-Jan-13 22:46 
AnswerRe: how to change the background color of a selected row in datagridview Pin
Richard MacCutchan31-Jan-13 22:38
mveRichard MacCutchan31-Jan-13 22:38 
GeneralRe: how to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 22:45
NarVish31-Jan-13 22:45 
QuestionHow to write events in event log using Log4net Pin
venkatpappu31-Jan-13 21:28
venkatpappu31-Jan-13 21:28 
AnswerRe: How to write events in event log using Log4net Pin
Richard MacCutchan31-Jan-13 22:11
mveRichard MacCutchan31-Jan-13 22:11 

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.