示例#1
0
            public DokHandlowyComparer(PropertyDescriptorPath sortPropertyPath, ListSortDirection sortDirection)
            {
                this.sortPropertyPath = sortPropertyPath;
                this.sortDirection    = sortDirection;

                var type  = typeof(Comparer <>).MakeGenericType(this.sortPropertyPath.Last.PropertyType);
                var pinfo = type.GetProperty("Default", BindingFlags.Static | BindingFlags.Public);

                this.defaultComparer = (IComparer)pinfo.GetValue(null, null);
            }
示例#2
0
        protected override void OnCellValueNeeded(DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                try
                {
                    DataGridViewRow        row    = this.Rows[e.RowIndex];
                    DataGridViewColumn     column = this.Columns[e.ColumnIndex];
                    PropertyDescriptorPath path   = new PropertyDescriptorPath(row.DataBoundItem.GetType(), column.DataPropertyName);
                    e.Value = path.GetValue(row.DataBoundItem);

                    /*
                     * PropertyPath path = new PropertyPath(row.DataBoundItem.GetType(), column.DataPropertyName);
                     * if (path != null)
                     *  e.Value = path.GetValue(row.DataBoundItem);
                     */
                }
                catch
                {
                    e.Value = null;
                }
            }
            base.OnCellValueNeeded(e);
        }