The DataSourceRow is a wrapper row class around the real bound data. This row is an abstraction so different types of data can be encaptulated in this class, although for the OutlookGrid it will simply look as one type of data. Note: this class does not implement all row wrappers optimally. It is merely used for demonstration purposes
Inheritance: System.Collections.CollectionBase
Ejemplo n.º 1
0
        private void InitList()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();
            var list = (IList)_dataSource;

            // use reflection to discover all properties of the object
            var bf    = BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty;
            var props = list[0].GetType().GetProperties();

            foreach (var pi in props)
            {
                Columns.Add(pi.Name);
            }

            foreach (var obj in list)
            {
                var row = new DataSourceRow(this, obj);
                foreach (var pi in props)
                {
                    var result = obj.GetType().InvokeMember(pi.Name, bf, null, obj, null);
                    row.Add(result);
                }
                Rows.Add(row);
            }
        }
Ejemplo n.º 2
0
        private void InitGrid()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();

            var 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)
                {
                    var row = new DataSourceRow(this, r);
                    for (var i = 0; i < Columns.Count; i++)
                    {
                        row.Add(r.Cells[i].Value);
                    }
                    Rows.Add(row);
                }
            }
        }
Ejemplo n.º 3
0
        private void InitDataSet()
        {
            Columns = new ArrayList();
            Rows    = new ArrayList();

            var table = _dataSource is DataSet ? ((DataSet)_dataSource).Tables[this._dataMember] : _dataSource as DataTable;

            // 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)
            {
                var row = new DataSourceRow(this, r);
                for (var i = 0; i < Columns.Count; i++)
                {
                    row.Add(r[i]);
                }
                Rows.Add(row);
            }
        }
Ejemplo n.º 4
0
        private void InitGrid()
        {
            Columns = new ArrayList();
            Rows = new ArrayList();

            var 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)
                {
                    var row = new DataSourceRow(this, r);
                    for (var i = 0; i < Columns.Count; i++)
                        row.Add(r.Cells[i].Value);
                    Rows.Add(row);
                }
            }
        }
Ejemplo n.º 5
0
        private void InitDataSet()
        {
            Columns = new ArrayList();
            Rows = new ArrayList();

            var table = _dataSource is DataSet ? ((DataSet)_dataSource).Tables[this._dataMember] : _dataSource as DataTable;
            // 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)
            {
                var row = new DataSourceRow(this, r);
                for (var i = 0; i < Columns.Count; i++)
                    row.Add(r[i]);
                Rows.Add(row);
            }
        }
Ejemplo n.º 6
0
        private void InitList()
        {
            Columns = new ArrayList();
            Rows = new ArrayList();
            var list = (IList)_dataSource;

            // use reflection to discover all properties of the object
            var bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty;
            var props = list[0].GetType().GetProperties();
            foreach (var pi in props)
                    Columns.Add(pi.Name);

            foreach (var obj in list)
            {
                var row = new DataSourceRow(this, obj);
                foreach (var pi in props)
                {
                    var result = obj.GetType().InvokeMember(pi.Name, bf, null, obj, null);
                    row.Add(result);
                }
                Rows.Add(row);
            }
        }