Click here to Skip to main content
15,180,347 members
Home / Discussions / C#
   

C#

 
QuestionHow to investigate ExecutionEngineException Pin
KASR11-Feb-13 23:21
MemberKASR11-Feb-13 23:21 
AnswerRe: How to investigate ExecutionEngineException Pin
Richard MacCutchan1-Feb-13 23:55
mveRichard MacCutchan1-Feb-13 23:55 
QuestionMdi Child Window Z-Order Pin
Richard Andrew x641-Feb-13 13:16
professionalRichard Andrew x641-Feb-13 13:16 
AnswerRe: Mdi Child Window Z-Order Pin
Jibesh1-Feb-13 13:43
professionalJibesh1-Feb-13 13:43 
GeneralRe: Mdi Child Window Z-Order Pin
Richard Andrew x641-Feb-13 14:08
professionalRichard Andrew x641-Feb-13 14:08 
GeneralRe: Mdi Child Window Z-Order Pin
Jibesh1-Feb-13 14:10
professionalJibesh1-Feb-13 14:10 
AnswerRe: Mdi Child Window Z-Order Pin
DaveyM692-Feb-13 0:57
professionalDaveyM692-Feb-13 0:57 
AnswerRe: Mdi Child Window Z-Order Pin
Alan N2-Feb-13 7:17
MemberAlan N2-Feb-13 7: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 6:41
Membervanikanc1-Feb-13 6:41 
AnswerRe: Strip special characters in row of data Pin
Eddy Vluggen1-Feb-13 7:53
professionalEddy Vluggen1-Feb-13 7:53 
AnswerRe: Strip special characters in row of data Pin
Ennis Ray Lynch, Jr.1-Feb-13 9:15
MemberEnnis Ray Lynch, Jr.1-Feb-13 9:15 
QuestionC#,ASP.Net Pin
sujeet3211-Feb-13 1:51
Membersujeet3211-Feb-13 1:51 
AnswerRe: C#,ASP.Net Pin
Simon_Whale1-Feb-13 2:06
professionalSimon_Whale1-Feb-13 2:06 
AnswerRe: C#,ASP.Net Pin
Dave Kreskowiak1-Feb-13 2:30
mveDave Kreskowiak1-Feb-13 2:30 
AnswerRe: C#,ASP.Net Pin
Abhinav S1-Feb-13 9:16
MemberAbhinav S1-Feb-13 9:16 
Questionhow to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 22:37
MemberNarVish31-Jan-13 22:37 
AnswerRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 23:21
mveOriginalGriff31-Jan-13 23:21 
GeneralRe: how to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 23:35
MemberNarVish31-Jan-13 23:35 
GeneralRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 23:38
mveOriginalGriff31-Jan-13 23:38 
GeneralRe: how to change the background color of a selected row in datagridview Pin
Richard MacCutchan31-Jan-13 23:39
mveRichard MacCutchan31-Jan-13 23:39 
GeneralRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 23:46
mveOriginalGriff31-Jan-13 23:46 
AnswerRe: how to change the background color of a selected row in datagridview Pin
Richard MacCutchan31-Jan-13 23:38
mveRichard MacCutchan31-Jan-13 23:38 
GeneralRe: how to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 23:45
MemberNarVish31-Jan-13 23:45 
QuestionHow to write events in event log using Log4net Pin
venkatpappu31-Jan-13 22:28
Membervenkatpappu31-Jan-13 22:28 
AnswerRe: How to write events in event log using Log4net Pin
Richard MacCutchan31-Jan-13 23:11
mveRichard MacCutchan31-Jan-13 23: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.