Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
ny way to alpha-sort the items shown by the MDIwindowList tool?
posted

I'd like to be able to either alpha-sort the contents of the MDI window list, or some means of affecting the order.

Is there some way to do this?

TIA

Pat

  • 4618
    posted

    Hi Pat,

    I have submitted the feature of sorting the MDIListTool's contents, as a product idea to our product management team, on your behalf.

    Our product team chooses new product ideas for development based on popular feedback from our customer base.  Infragistics continues to monitor application development for all of our products, so as trends appear in requested features, we can plan accordingly.

    We value your input, and our philosophy is to enhance our toolset based on customer feedback.  If your feature is chosen for development, you will be notified at that time.  Your reference number for this product idea is PI12050046.

    If you would like to follow up on your product idea at a later point, you may contact Developer Support management via email.  Please include the reference number of your product idea in the subject and body of your email message.  You can reach Developer Support management through the following email address:  dsmanager@infragistics.com

    Thank you for your request.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support

  • 6158
    Suggested Answer
    Offline posted

    Hello Pat.

    The MdiWindowListTool build its list of Windows based on the parent Form's MdiChildren array. The Form gets this list from an internal ArrayList in the MdiClient. Unfortunately, there is no sorting mechanism built into the MdiWindowListTool to allow you to manipulate the order.  You can submit a feature request to add this functionality here.

    However, with a little reflection, you can sort the internal list using the follow code whenever a new child form is added:

     

            private ArrayList internalList;

            private void SortChildForms()

            {

     

                if (this.internalList == null)

                {

                    //find the MdiClient

                    foreach (Control control in this.Controls)

                    {

                        MdiClient mdiClient = control as MdiClient;

                        if (mdiClient != null)

                        {

                            // use reflection to get the underlying children array

                            Type mdiType = mdiClient.GetType();

                            this.internalList = (ArrayList)mdiType.InvokeMember("children", System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, null, mdiClient, null);

                            break;

                        }

                    }

                }

     

                // sort the children array

                this.internalList.Sort(new MdiChildComparer());

            }

     

            internal class MdiChildComparer : IComparer

            {

     

                #region IComparer Members

     

                public int Compare(object x, object y)

                {

                    return string.Compare(((Form)x).Text, ((Form)y).Text);

                }

     

                #endregion

            }

    I hope this helps you achieve your desired results. Let me know if I can be of any further assistance.

    Chris