public int Compare(object x, object y)
        {
            DataSourceRow r1 = (DataSourceRow)x;
            DataSourceRow r2 = (DataSourceRow)y;

            return(baseComparer.Compare(r1.BoundItem, r2.BoundItem));
        }
        private void InitGrid()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();

            OutlookGrid grid = (OutlookGrid)dataSource;

            // use reflection to discover all properties of the object
            foreach (DataGridViewColumn c in grid.Columns)
            {
                Columns.Add(c.Name);
            }

            foreach (OutlookGridRow r in grid.Rows)
            {
                if (!r.IsGroupRow && !r.IsNewRow)
                {
                    DataSourceRow row = new DataSourceRow(this, r);
                    for (int i = 0; i < Columns.Count; i++)
                    {
                        row.Add(r.Cells[i].Value);
                    }
                    Rows.Add(row);
                }
            }
        }
        private void InitList()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();
            IList list = (IList)dataSource;

            // use reflection to discover all properties of the object
            BindingFlags bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty;

            PropertyInfo[] props = list[0].GetType().GetProperties();
            foreach (PropertyInfo pi in props)
            {
                Columns.Add(pi.Name);
            }

            foreach (object obj in list)
            {
                DataSourceRow row = new DataSourceRow(this, obj);
                foreach (PropertyInfo pi in props)
                {
                    object result = obj.GetType().InvokeMember(pi.Name, bf, null, obj, null);
                    row.Add(result);
                }
                Rows.Add(row);
            }
        }
        private void InitDataSet()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();

            DataTable table = ((DataSet)dataSource).Tables[this.dataMember];

            // use reflection to discover all properties of the object
            foreach (DataColumn c in table.Columns)
            {
                Columns.Add(c.ColumnName);
            }

            foreach (DataRow r in table.Rows)
            {
                DataSourceRow row = new DataSourceRow(this, r);
                for (int i = 0; i < Columns.Count; i++)
                {
                    row.Add(r[i]);
                }
                Rows.Add(row);
            }
        }